diff --git a/.github/workflows/fireback-build.yml b/.github/workflows/fireback-build.yml index c6ce14354..5100b003f 100644 --- a/.github/workflows/fireback-build.yml +++ b/.github/workflows/fireback-build.yml @@ -26,40 +26,35 @@ on: # - windows-x64 # - macosx release_artifacts: - description: "Create a draft release with all artifacts" + description: "Create draft release" required: false default: false type: boolean github_pages: - description: "Deploy documents and fireback react to github pages" + description: "Deploy docs and demo to pages" required: false default: false type: boolean - deploy_npm: - description: "Publish fireback ui libraries to npm" - required: false - default: false - type: boolean - + fireback_windows: - description: "Build for windows" + description: "Build Windows" required: false - default: true + default: false type: boolean fireback_macos: - description: "Build for macos" + description: "Build Macosx" required: false - default: true + default: false type: boolean fireback_react: - description: "Build Fireback React" + description: "Build Fireback React Front-end" required: false - default: true + default: false type: boolean fireback_capacitor: - description: "Build Capacitor" + description: "Build Capacitor Demo" required: false - default: true + default: false type: boolean jobs: @@ -443,25 +438,6 @@ jobs: git diff --name-only exit 1 fi - - fireback-npm: - if: ${{ inputs.deploy_npm == true }} - runs-on: ubuntu-latest - steps: - - name: checkout repository - uses: actions/checkout@v3 - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: "lts/*" - registry-url: "https://registry.npmjs.org" - - - run: | - cd modules/fireback/codegen/react-new/src/modules/fireback && npm version --no-git-tag-version 1.3.2-${{ github.sha }} && npm publish --tag=latest --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }} - NPM_TOKEN: ${{ secrets.NPM_PUBLISH }} - fireback-capacitor: if: ${{ inputs.fireback_capacitor == true }} diff --git a/.gitignore b/.gitignore index 7be922927..ede31d6cd 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,6 @@ dist ui/public/md cachemap.txt cachemap.json -cmd/fireback-desktop/build/bin -cmd/fireback-npm/**/*/fireback -cmd/fireback-npm/**/*/fireback.exe google-java-format.jar *.msi *.wixpdb diff --git a/cmd/fireback-npm/cli-darwin-arm64/README.md b/cmd/fireback-npm/cli-darwin-arm64/README.md deleted file mode 100644 index 72caa8a12..000000000 --- a/cmd/fireback-npm/cli-darwin-arm64/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Fireback Cli Darwin Binary - -This package contains the Fireback Cli binary for darwin. - -See https://github.com/torabian/fireback for more information. diff --git a/cmd/fireback-npm/cli-darwin-arm64/package.json b/cmd/fireback-npm/cli-darwin-arm64/package.json deleted file mode 100644 index 0a491fdc7..000000000 --- a/cmd/fireback-npm/cli-darwin-arm64/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@fireback/cli-darwin-arm64", - "version": "0.0.12", - "description": "The darwin distribution of the fireback cli binary.", - "repository": "https://github.com/torabian/fireback", - "license": "BSD-3-Clause", - "publishConfig": { - "access": "public" - }, - "engines": { - "node": ">=10" - }, - "os": [ - "darwin" - ], - "cpu": [ - "x64" - ] -} \ No newline at end of file diff --git a/cmd/fireback-npm/cli-darwin-x64/README.md b/cmd/fireback-npm/cli-darwin-x64/README.md deleted file mode 100644 index 72caa8a12..000000000 --- a/cmd/fireback-npm/cli-darwin-x64/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Fireback Cli Darwin Binary - -This package contains the Fireback Cli binary for darwin. - -See https://github.com/torabian/fireback for more information. diff --git a/cmd/fireback-npm/cli-darwin-x64/package.json b/cmd/fireback-npm/cli-darwin-x64/package.json deleted file mode 100644 index 7eec8817b..000000000 --- a/cmd/fireback-npm/cli-darwin-x64/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@fireback/cli-darwin-x64", - "version": "0.0.12", - "description": "The darwin distribution of the fireback cli binary.", - "repository": "https://github.com/torabian/fireback", - "license": "BSD-3-Clause", - "publishConfig": { - "access": "public" - }, - "engines": { - "node": ">=10" - }, - "os": [ - "darwin" - ], - "cpu": [ - "x64" - ] -} \ No newline at end of file diff --git a/cmd/fireback-npm/cli-linux-x64/README.md b/cmd/fireback-npm/cli-linux-x64/README.md deleted file mode 100644 index 72caa8a12..000000000 --- a/cmd/fireback-npm/cli-linux-x64/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Fireback Cli Darwin Binary - -This package contains the Fireback Cli binary for darwin. - -See https://github.com/torabian/fireback for more information. diff --git a/cmd/fireback-npm/cli-linux-x64/package.json b/cmd/fireback-npm/cli-linux-x64/package.json deleted file mode 100644 index 44ab9c9c7..000000000 --- a/cmd/fireback-npm/cli-linux-x64/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@fireback/cli-linux-x64", - "version": "0.0.11", - "description": "The linux x64 distribution of the fireback cli binary.", - "repository": "https://github.com/torabian/fireback", - "license": "BSD-3-Clause", - "publishConfig": { - "access": "public" - }, - "engines": { - "node": ">=10" - }, - "os": [ - "linux", - "freebsd" - ], - "cpu": [ - "x64" - ] -} \ No newline at end of file diff --git a/cmd/fireback-npm/cli-win32-x64/README.md b/cmd/fireback-npm/cli-win32-x64/README.md deleted file mode 100644 index 72caa8a12..000000000 --- a/cmd/fireback-npm/cli-win32-x64/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Fireback Cli Darwin Binary - -This package contains the Fireback Cli binary for darwin. - -See https://github.com/torabian/fireback for more information. diff --git a/cmd/fireback-npm/cli-win32-x64/package.json b/cmd/fireback-npm/cli-win32-x64/package.json deleted file mode 100644 index fdcf8e548..000000000 --- a/cmd/fireback-npm/cli-win32-x64/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@fireback/cli-win32-x64", - "version": "0.0.12", - "description": "The win32 x64 distribution of the fireback cli binary.", - "repository": "https://github.com/torabian/fireback", - "license": "BSD-3-Clause", - "publishConfig": { - "access": "public" - }, - "engines": { - "node": ">=10" - }, - "os": [ - "win32" - ], - "cpu": [ - "x64" - ] -} \ No newline at end of file diff --git a/cmd/fireback-npm/cli/js/helper.js b/cmd/fireback-npm/cli/js/helper.js deleted file mode 100644 index eae9ffdc5..000000000 --- a/cmd/fireback-npm/cli/js/helper.js +++ /dev/null @@ -1,367 +0,0 @@ -"use strict"; - -const os = require("os"); -const path = require("path"); -const fs = require("fs"); -const childProcess = require("child_process"); - -const BINARY_DISTRIBUTIONS = [ - { packageName: "@fireback/cli-darwin", subpath: "bin/fireback" }, - { packageName: "@fireback/cli-linux-x64", subpath: "bin/fireback" }, - { packageName: "@fireback/cli-linux-i686", subpath: "bin/fireback" }, - { packageName: "@fireback/cli-linux-arm64", subpath: "bin/fireback" }, - { packageName: "@fireback/cli-linux-arm", subpath: "bin/fireback" }, - { packageName: "@fireback/cli-win32-x64", subpath: "bin/fireback.exe" }, - { packageName: "@fireback/cli-win32-i686", subpath: "bin/fireback.exe" }, -]; - -/** - * This convoluted function resolves the path to the manually downloaded fallback - * `fireback` binary in a way that can't be analysed by @vercel/nft. - * - * Without this, the binary can be detected as an asset and included by bundlers - * that use @vercel/nft. - * - * @returns {string} The path to the fireback binary - */ -function getFallbackBinaryPath() { - const parts = []; - parts.push(__dirname); - parts.push(".."); - parts.push(`fireback${process.platform === "win32" ? ".exe" : ""}`); - return path.resolve(...parts); -} - -function getDistributionForThisPlatform() { - const arch = os.arch(); - const platform = os.platform(); - - let packageName = undefined; - if (platform === "darwin") { - if (arch === "x64") { - packageName = "@fireback/cli-darwin-x64"; - } - } else if (platform === "linux" || platform === "freebsd") { - switch (arch) { - case "x64": - packageName = "@fireback/cli-linux-x64"; - break; - case "x86": - case "ia32": - packageName = "@fireback/cli-linux-i686"; - break; - case "arm64": - packageName = "@fireback/cli-linux-arm64"; - break; - case "arm": - packageName = "@fireback/cli-linux-arm"; - break; - } - } else if (platform === "win32") { - switch (arch) { - case "x64": - // Windows arm64 can run x64 binaries - case "arm64": - packageName = "@fireback/cli-win32-x64"; - break; - case "x86": - case "ia32": - packageName = "@fireback/cli-win32-i686"; - break; - } - } - - let subpath = undefined; - switch (platform) { - case "win32": - subpath = "bin/fireback.exe"; - break; - case "darwin": - case "linux": - case "freebsd": - subpath = "bin/fireback"; - break; - default: - subpath = "bin/fireback"; - break; - } - - return { packageName, subpath }; -} - -/** - * Throws an error with a message stating that Fireback CLI doesn't support the current platform. - * - * @returns {never} nothing. It throws. - */ -function throwUnsupportedPlatformError() { - throw new Error( - `Unsupported operating system or architecture! Fireback CLI does not work on this architecture. - -Fireback CLI supports: -- Darwin (macOS) -- Linux and FreeBSD on x64, x86, ia32, arm64, and arm architectures -- Windows x64, x86, and ia32 architectures` - ); -} - -/** - * Tries to find the installed Fireback CLI binary - either by looking into the relevant - * optional dependencies or by trying to resolve the fallback binary. - * - * @returns {string} The path to the fireback binary - */ -function getBinaryPath() { - if (process.env.FIREBACK_BINARY_PATH) { - return process.env.FIREBACK_BINARY_PATH; - } - - const { packageName, subpath } = getDistributionForThisPlatform(); - - if (packageName === undefined) { - throwUnsupportedPlatformError(); - } - - let fallbackBinaryPath = getFallbackBinaryPath(); - if (fs.existsSync(fallbackBinaryPath)) { - // Since the fallback got installed, the optional dependencies likely didn't get installed, so we just default to the fallback. - return fallbackBinaryPath; - } - - let compatibleBinaryPath; - try { - compatibleBinaryPath = require.resolve(`${packageName}/${subpath}`); - } catch (e) { - const otherInstalledDistribution = BINARY_DISTRIBUTIONS.find( - ({ packageName, subpath }) => { - try { - require.resolve(`${packageName}/${subpath}`); - return true; - } catch (e) { - return false; - } - } - ); - - // These error messages are heavily inspired by esbuild's error messages: https://github.com/evanw/esbuild/blob/f3d535262e3998d845d0f102b944ecd5a9efda57/lib/npm/node-platform.ts#L150 - if (otherInstalledDistribution) { - throw new Error(`Fireback CLI binary for this platform/architecture not found! - -The "${otherInstalledDistribution.packageName}" package is installed, but for the current platform, you should have the "${packageName}" package installed instead. This usually happens if the "@fireback/cli" package is installed on one platform (for example Windows or MacOS) and then the "node_modules" folder is reused on another operating system (for example Linux in Docker). - -To fix this, avoid copying the "node_modules" folder, and instead freshly install your dependencies on the target system. You can also configure your package manager to install the right package. For example, yarn has the "supportedArchitectures" feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitecture.`); - } else { - throw new Error(`Fireback CLI binary for this platform/architecture not found! - -Looking for ${packageName}, but it's not there. - -It seems like none of the "@fireback/cli" package's optional dependencies got installed. Please make sure your package manager is configured to install optional dependencies. If you are using npm to install your dependencies, please don't set the "--no-optional", "--ignore-optional", or "--omit=optional" flags. Fireback CLI needs the "optionalDependencies" feature in order to install its binary.`); - } - } - - return compatibleBinaryPath; -} - -/** - * Will be used as the binary path when defined with `mockBinaryPath`. - * @type {string | undefined} - */ -let mockedBinaryPath; - -/** - * Overrides the default binary path with a mock value, useful for testing. - * - * @param {string} mockPath The new path to the mock fireback binary - * @deprecated This was used in tests internally and will be removed in the next major version. - */ -// TODO(v3): Remove this function -function mockBinaryPath(mockPath) { - mockedBinaryPath = mockPath; -} - -/** - * The javascript type of a command line option. - * @typedef {'array'|'string'|'boolean'|'inverted-boolean'} OptionType - */ - -/** - * Schema definition of a command line option. - * @typedef {object} OptionSchema - * @prop {string} param The flag of the command line option including dashes. - * @prop {OptionType} type The value type of the command line option. - */ - -/** - * Schema definition for a command. - * @typedef {Object.} OptionsSchema - */ - -/** - * Serializes command line options into an arguments array. - * - * @param {OptionsSchema} schema An options schema required by the command. - * @param {object} options An options object according to the schema. - * @returns {string[]} An arguments array that can be passed via command line. - */ -function serializeOptions(schema, options) { - return Object.keys(schema).reduce((newOptions, option) => { - const paramValue = options[option]; - if (paramValue === undefined || paramValue === null) { - return newOptions; - } - - const paramType = schema[option].type; - const paramName = schema[option].param; - - if (paramType === "array") { - if (!Array.isArray(paramValue)) { - throw new Error(`${option} should be an array`); - } - - return newOptions.concat( - paramValue.reduce( - (acc, value) => acc.concat([paramName, String(value)]), - [] - ) - ); - } - - if (paramType === "boolean") { - if (typeof paramValue !== "boolean") { - throw new Error(`${option} should be a bool`); - } - - const invertedParamName = schema[option].invertedParam; - - if (paramValue && paramName !== undefined) { - return newOptions.concat([paramName]); - } - - if (!paramValue && invertedParamName !== undefined) { - return newOptions.concat([invertedParamName]); - } - - return newOptions; - } - - return newOptions.concat(paramName, paramValue); - }, []); -} - -/** - * Serializes the command and its options into an arguments array. - * - * @param {string} command The literal name of the command. - * @param {OptionsSchema} [schema] An options schema required by the command. - * @param {object} [options] An options object according to the schema. - * @returns {string[]} An arguments array that can be passed via command line. - */ -function prepareCommand(command, schema, options) { - return command.concat(serializeOptions(schema || {}, options || {})); -} - -/** - * Returns the absolute path to the `fireback` binary. - * @returns {string} - */ -function getPath() { - return mockedBinaryPath !== undefined ? mockedBinaryPath : getBinaryPath(); -} - -/** - * Runs `fireback` with the given command line arguments. - * - * Use {@link prepareCommand} to specify the command and add arguments for command- - * specific options. For top-level options, use {@link serializeOptions} directly. - * - * The returned promise resolves with the standard output of the command invocation - * including all newlines. In order to parse this output, be sure to trim the output - * first. - * - * If the command failed to execute, the Promise rejects with the error returned by the - * CLI. This error includes a `code` property with the process exit status. - * - * @example - * const output = await execute(['--version']); - * expect(output.trim()).toBe('fireback x.y.z'); - * - * @param {string[]} args Command line arguments passed to `fireback`. - * @param {boolean} live We inherit stdio to display `fireback` output directly. - * @param {boolean} silent Disable stdout for silents build (CI/Webpack Stats, ...) - * @param {string} [configFile] Relative or absolute path to the configuration file. - * @param {Object} [config] More configuration to pass to the CLI - * @returns {Promise.} A promise that resolves to the standard output. - */ -async function execute(args, live, silent, configFile, config = {}) { - const env = { ...process.env }; - if (configFile) { - env.FIREBACK_PROPERTIES = configFile; - } - if (config.url) { - env.FIREBACK_URL = config.url; - } - if (config.authToken) { - env.FIREBACK_AUTH_TOKEN = config.authToken; - } - if (config.apiKey) { - env.FIREBACK_API_KEY = config.apiKey; - } - if (config.dsn) { - env.FIREBACK_DSN = config.dsn; - } - if (config.org) { - env.FIREBACK_ORG = config.org; - } - if (config.project) { - env.FIREBACK_PROJECT = config.project; - } - if (config.vcsRemote) { - env.FIREBACK_VCS_REMOTE = config.vcsRemote; - } - if (config.customHeader) { - env.CUSTOM_HEADER = config.customHeader; - } else if (config.headers) { - const headers = Object.entries(config.headers).flatMap(([key, value]) => [ - "--header", - `${key}:${value}`, - ]); - args = [...headers, ...args]; - } - return new Promise((resolve, reject) => { - if (live === true) { - const output = silent ? "ignore" : "inherit"; - const pid = childProcess.spawn(getPath(), args, { - env, - // stdin, stdout, stderr - stdio: ["ignore", output, output], - }); - pid.on("exit", () => { - resolve(); - }); - } else { - childProcess.execFile(getPath(), args, { env }, (err, stdout) => { - if (err) { - reject(err); - } else { - resolve(stdout); - } - }); - } - }); -} - -function getProjectFlagsFromOptions({ projects = [] } = {}) { - return projects.reduce((flags, project) => flags.concat("-p", project), []); -} - -module.exports = { - execute, - getPath, - getProjectFlagsFromOptions, - mockBinaryPath, - prepareCommand, - serializeOptions, - getDistributionForThisPlatform, - throwUnsupportedPlatformError, - getFallbackBinaryPath, -}; diff --git a/cmd/fireback-npm/cli/js/index.js b/cmd/fireback-npm/cli/js/index.js deleted file mode 100644 index 6f11b7b5b..000000000 --- a/cmd/fireback-npm/cli/js/index.js +++ /dev/null @@ -1,74 +0,0 @@ -"use strict"; - -const pkgInfo = require("../package.json"); -const helper = require("./helper"); -const Releases = require("./releases"); - -/** - * Interface to and wrapper around the `fireback` executable. - * - * Commands are grouped into namespaces. See the respective namespaces for more - * documentation. To use this wrapper, simply create an instance and call methods: - * - * @example - * const cli = new FirebackCli(); - * console.log(FirebackCli.getVersion()); - * - * @example - * const cli = new FirebackCli('path/to/custom/fireback.properties'); - * const release = await cli.releases.proposeVersion()); - * console.log(release); - */ -class FirebackCli { - /** - * Creates a new `FirebackCli` instance. - * - * If the `configFile` parameter is specified, configuration located in the default - * location and the value specified in the `FIREBACK_PROPERTIES` environment variable is - * overridden. - * - * @param {string} [configFile] Relative or absolute path to the configuration file. - * @param {Object} [options] More options to pass to the CLI - */ - constructor(configFile, options) { - if (typeof configFile === "string") { - this.configFile = configFile; - } - this.options = options || { silent: false }; - this.releases = new Releases({ ...this.options, configFile }); - } - - /** - * Returns the version of the installed `fireback` binary. - * @returns {string} - */ - static getVersion() { - return pkgInfo.version; - } - - /** - * Returns an absolute path to the `fireback` binary. - * @returns {string} - */ - static getPath() { - return helper.getPath(); - } - - /** - * See {helper.execute} docs. - * @param {string[]} args Command line arguments passed to `fireback`. - * @param {boolean} live We inherit stdio to display `fireback` output directly. - * @returns {Promise.} A promise that resolves to the standard output. - */ - execute(args, live) { - return helper.execute( - args, - live, - this.options.silent, - this.configFile, - this.options - ); - } -} - -module.exports = FirebackCli; diff --git a/cmd/fireback-npm/cli/js/logger.js b/cmd/fireback-npm/cli/js/logger.js deleted file mode 100644 index 88eabbdff..000000000 --- a/cmd/fireback-npm/cli/js/logger.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -const format = require("util").format; - -module.exports = class Logger { - constructor(stream) { - this.stream = stream; - } - - log() { - const message = format(...arguments); - this.stream.write(`[fireback] ${message}\n`); - } -}; diff --git a/cmd/fireback-npm/cli/js/releases/index.js b/cmd/fireback-npm/cli/js/releases/index.js deleted file mode 100644 index 880ecf3da..000000000 --- a/cmd/fireback-npm/cli/js/releases/index.js +++ /dev/null @@ -1,289 +0,0 @@ -"use strict"; - -const helper = require("../helper"); - -/** - * Default arguments for the `--ignore` option. - * @type {string[]} - */ -const DEFAULT_IGNORE = ["node_modules"]; - -/** - * Schema for the `upload-sourcemaps` command. - * @type {OptionsSchema} - */ -const SOURCEMAPS_SCHEMA = require("./options/uploadSourcemaps"); - -/** - * Schema for the `deploys new` command. - * @type {OptionsSchema} - */ -const DEPLOYS_SCHEMA = require("./options/deploys"); - -/** - * Manages releases and release artifacts on Fireback. - * @namespace FirebackReleases - */ -class Releases { - /** - * Creates a new `Releases` instance. - * - * @param {Object} [options] More options to pass to the CLI - */ - constructor(options) { - this.options = options || {}; - if (typeof this.options.configFile === "string") { - this.configFile = this.options.configFile; - } - delete this.options.configFile; - } - - /** - * Registers a new release with fireback. - * - * The given release name should be unique and deterministic. It can later be used to - * upload artifacts, such as source maps. - * - * @param {string} release Unique name of the new release. - * @param {object} options A set of options when creating a release. - * @param {array} options.projects The list of project slugs for a release. - * @returns {Promise} A promise that resolves when the release has been created. - * @memberof FirebackReleases - */ - async new(release, options) { - const args = ["releases", "new", release].concat( - helper.getProjectFlagsFromOptions(options) - ); - return this.execute(args, null); - } - - /** - * Specifies the set of commits covered in this release. - * - * @param {string} release Unique name of the release - * @param {object} options A set of options to configure the commits to include - * @param {string} options.repo The full repo name as defined in Fireback - * @param {boolean} options.auto Automatically choose the associated commit (uses - * the current commit). Overrides other options. - * @param {string} options.commit The current (last) commit in the release. - * @param {string} options.previousCommit The commit before the beginning of this - * release (in other words, the last commit of the previous release). If omitted, - * this will default to the last commit of the previous release in Fireback. If there - * was no previous release, the last 10 commits will be used. - * @param {boolean} options.ignoreMissing When the flag is set and the previous release - * commit was not found in the repository, will create a release with the default commits - * count (or the one specified with `--initial-depth`) instead of failing the command. - * @param {boolean} options.ignoreEmpty When the flag is set, command will not fail - * and just exit silently if no new commits for a given release have been found. - * @returns {Promise} A promise that resolves when the commits have been associated - * @memberof FirebackReleases - */ - async setCommits(release, options) { - if (!options || (!options.auto && (!options.repo || !options.commit))) { - throw new Error( - "options.auto, or options.repo and options.commit must be specified" - ); - } - - let commitFlags = []; - - if (options.auto) { - commitFlags = ["--auto"]; - } else if (options.previousCommit) { - commitFlags = [ - "--commit", - `${options.repo}@${options.previousCommit}..${options.commit}`, - ]; - } else { - commitFlags = ["--commit", `${options.repo}@${options.commit}`]; - } - - if (options.ignoreMissing) { - commitFlags.push("--ignore-missing"); - } - - return this.execute( - ["releases", "set-commits", release].concat(commitFlags) - ); - } - - /** - * Marks this release as complete. This should be called once all artifacts has been - * uploaded. - * - * @param {string} release Unique name of the release. - * @returns {Promise} A promise that resolves when the release has been finalized. - * @memberof FirebackReleases - */ - async finalize(release) { - return this.execute(["releases", "finalize", release], null); - } - - /** - * Creates a unique, deterministic version identifier based on the project type and - * source files. This identifier can be used as release name. - * - * @returns {Promise.} A promise that resolves to the version string. - * @memberof FirebackReleases - */ - async proposeVersion() { - const version = await this.execute(["releases", "propose-version"], null); - return version.trim(); - } - - /** - * Scans the given include folders for JavaScript source maps and uploads them to the - * specified release for processing. - * - * The options require an `include` array, which is a list of directories to scan. - * Additionally, it supports to ignore certain files, validate and preprocess source - * maps and define a URL prefix. - * - * @example - * await cli.releases.uploadSourceMaps(cli.releases.proposeVersion(), { - * // required options: - * include: ['build'], - * - * // default options: - * ignore: ['node_modules'], // globs for files to ignore - * ignoreFile: null, // path to a file with ignore rules - * rewrite: false, // preprocess sourcemaps before uploading - * sourceMapReference: true, // add a source map reference to source files - * dedupe: true, // deduplicate already uploaded files - * stripPrefix: [], // remove certain prefices from filenames - * stripCommonPrefix: false, // guess common prefices to remove from filenames - * validate: false, // validate source maps and cancel the upload on error - * urlPrefix: '', // add a prefix source map urls after stripping them - * urlSuffix: '', // add a suffix source map urls after stripping them - * ext: ['js', 'map', 'jsbundle', 'bundle'], // override file extensions to scan for - * projects: ['node'], // provide a list of projects - * decompress: false // decompress gzip files before uploading - * }); - * - * @param {string} release Unique name of the release. - * @param {object} options Options to configure the source map upload. - * @returns {Promise} A promise that resolves when the upload has completed successfully. - * @memberof FirebackReleases - */ - async uploadSourceMaps(release, options) { - if (!options || !options.include || !Array.isArray(options.include)) { - throw new Error( - "`options.include` must be a vaild array of paths and/or path descriptor objects." - ); - } - - // Each entry in the `include` array will map to an array of promises, which - // will in turn contain one promise per literal path value. Thus `uploads` - // will be an array of Promise arrays, which we'll flatten later. - const uploads = options.include.map((includeEntry) => { - let pathOptions; - let uploadPaths; - - if (typeof includeEntry === "object") { - pathOptions = includeEntry; - uploadPaths = includeEntry.paths; - - if (!Array.isArray(uploadPaths)) { - throw new Error( - `Path descriptor objects in \`options.include\` must contain a \`paths\` array. Got ${includeEntry}.` - ); - } - } - // `includeEntry` should be a string, which we can wrap in an array to - // match the `paths` property in the descriptor object type - else { - pathOptions = {}; - uploadPaths = [includeEntry]; - } - - const newOptions = { ...options, ...pathOptions }; - if (!newOptions.ignoreFile && !newOptions.ignore) { - newOptions.ignore = DEFAULT_IGNORE; - } - - // args which apply to the entire `include` entry (everything besides the path) - const args = ["releases"] - .concat(helper.getProjectFlagsFromOptions(options)) - .concat(["files", release, "upload-sourcemaps"]); - - return uploadPaths.map((path) => - // `execute()` is async and thus we're returning a promise here - this.execute( - helper.prepareCommand([...args, path], SOURCEMAPS_SCHEMA, newOptions), - true - ) - ); - }); - - // `uploads` is an array of Promise arrays, which needs to be flattened - // before being passed to `Promise.all()`. (`Array.flat()` doesn't exist in - // Node < 11; this polyfill takes advantage of the fact that `concat()` is - // willing to accept an arbitrary number of items to add to and/or iterables - // to unpack into the given array.) - return Promise.all([].concat(...uploads)); - } - - /** - * List all deploys for a given release. - * - * @param {string} release Unique name of the release. - * @returns {Promise} A promise that resolves when the list comes back from the server. - * @memberof FirebackReleases - */ - async listDeploys(release) { - return this.execute(["releases", "deploys", release, "list"], null); - } - - /** - * Creates a new release deployment. This should be called after the release has been - * finalized, while deploying on a given environment. - * - * @example - * await cli.releases.newDeploy(cli.releases.proposeVersion(), { - * // required options: - * env: 'production', // environment for this release. Values that make sense here would be -'production' or 'staging' - * - * // optional options: - * started: 42, // unix timestamp when the deployment started - * finished: 1337, // unix timestamp when the deployment finished - * time: 1295, // deployment duration in seconds. This can be specified alternatively to -`started` and `finished` - * name: 'PickleRick', // human readable name for this deployment - * url: 'https://example.com', // URL that points to the deployment - * }); - * - * @param {string} release Unique name of the release. - * @param {object} options Options to configure the new release deploy. - * @returns {Promise} A promise that resolves when the deploy has been created. - * @memberof FirebackReleases - */ - async newDeploy(release, options) { - if (!options || !options.env) { - throw new Error("options.env must be a vaild name"); - } - const args = ["releases", "deploys", release, "new"]; - return this.execute( - helper.prepareCommand(args, DEPLOYS_SCHEMA, options), - null - ); - } - - /** - * See {helper.execute} docs. - * @param {string[]} args Command line arguments passed to `fireback`. - * @param {boolean} live We inherit stdio to display `fireback` output directly. - * @returns {Promise.} A promise that resolves to the standard output. - */ - async execute(args, live) { - return helper.execute( - args, - live, - this.options.silent, - this.configFile, - this.options - ); - } -} - -module.exports = Releases; diff --git a/cmd/fireback-npm/cli/js/releases/options/deploys.js b/cmd/fireback-npm/cli/js/releases/options/deploys.js deleted file mode 100644 index fbe7051ec..000000000 --- a/cmd/fireback-npm/cli/js/releases/options/deploys.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - env: { - param: "--env", - type: "string", - }, - started: { - param: "--started", - type: "number", - }, - finished: { - param: "--finished", - type: "number", - }, - time: { - param: "--time", - type: "number", - }, - name: { - param: "--name", - type: "string", - }, - url: { - param: "--url", - type: "string", - }, -}; diff --git a/cmd/fireback-npm/cli/js/releases/options/uploadSourcemaps.js b/cmd/fireback-npm/cli/js/releases/options/uploadSourcemaps.js deleted file mode 100644 index 54ae8cb3d..000000000 --- a/cmd/fireback-npm/cli/js/releases/options/uploadSourcemaps.js +++ /dev/null @@ -1,59 +0,0 @@ -module.exports = { - ignore: { - param: "--ignore", - type: "array", - }, - ignoreFile: { - param: "--ignore-file", - type: "string", - }, - dist: { - param: "--dist", - type: "string", - }, - decompress: { - param: "--decompress", - type: "boolean", - }, - rewrite: { - param: "--rewrite", - invertedParam: "--no-rewrite", - type: "boolean", - }, - sourceMapReference: { - invertedParam: "--no-sourcemap-reference", - type: "boolean", - }, - dedupe: { - invertedParam: "--no-dedupe", - type: "boolean", - }, - stripPrefix: { - param: "--strip-prefix", - type: "array", - }, - stripCommonPrefix: { - param: "--strip-common-prefix", - type: "boolean", - }, - validate: { - param: "--validate", - type: "boolean", - }, - urlPrefix: { - param: "--url-prefix", - type: "string", - }, - urlSuffix: { - param: "--url-suffix", - type: "string", - }, - ext: { - param: "--ext", - type: "array", - }, - useArtifactBundle: { - param: "--use-artifact-bundle", - type: "boolean", - }, -}; diff --git a/cmd/fireback-npm/cli/package-lock.json b/cmd/fireback-npm/cli/package-lock.json deleted file mode 100644 index 38aa1b12f..000000000 --- a/cmd/fireback-npm/cli/package-lock.json +++ /dev/null @@ -1,192 +0,0 @@ -{ - "name": "@fireback/cli", - "version": "0.0.12", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "@fireback/cli", - "version": "0.0.12", - "hasInstallScript": true, - "license": "ISC", - "dependencies": { - "https-proxy-agent": "^5.0.0", - "node-fetch": "^2.6.7", - "progress": "^2.0.3", - "proxy-from-env": "^1.1.0", - "which": "^2.0.2" - }, - "bin": { - "fireback": "bin/fireback" - }, - "engines": { - "node": ">= 10" - }, - "optionalDependencies": { - "@fireback/cli-darwin-arm64": "0.0.12", - "@fireback/cli-darwin-x64": "0.0.12", - "@fireback/cli-linux-x64": "0.0.12", - "@fireback/cli-win32-x64": "0.0.12" - } - }, - "node_modules/@fireback/cli-darwin-arm64": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/@fireback/cli-darwin-arm64/-/cli-darwin-arm64-0.0.12.tgz", - "integrity": "sha512-Fso8ynS943/l14XtCSQOJalvgYrx2a/KnzX08Pot8Kf/a5YzkDwC3WretLOIOdf3jEuJoX+3HV2Kxuks7sa6gQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@fireback/cli-darwin-x64": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/@fireback/cli-darwin-x64/-/cli-darwin-x64-0.0.12.tgz", - "integrity": "sha512-/9kMYR/i8A10G5ry9A+nUgpsoXuiODDswze0CRveZPwMIyKduqHOhl6RLb5RgLDQ+AwNcAFO+722eFG03cbh3A==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/@fireback/cli-win32-x64": { - "version": "0.0.12", - "resolved": "https://registry.npmjs.org/@fireback/cli-win32-x64/-/cli-win32-x64-0.0.12.tgz", - "integrity": "sha512-mzv4B3blsfZ6pqV4xGD+5kqnZ2MwpVOnvf3Ln+CZxT49XChEKONrKO353kKbdn+DnZylqpeLTTzkgXnEcaIw3Q==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=10" - } - }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/debug": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", - "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - } - } -} diff --git a/cmd/fireback-npm/cli/package.json b/cmd/fireback-npm/cli/package.json deleted file mode 100644 index cc782f6dd..000000000 --- a/cmd/fireback-npm/cli/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "@fireback/cli", - "version": "0.0.12", - "description": "Fireback backend and code gen tools for javascript world", - "main": "index.js", - "private": false, - "publishConfig": { - "access": "public" - }, - "engines": { - "node": ">= 10" - }, - "dependencies": { - "https-proxy-agent": "^5.0.0", - "node-fetch": "^2.6.7", - "progress": "^2.0.3", - "proxy-from-env": "^1.1.0", - "which": "^2.0.2" - }, - "bin": { - "fireback": "bin/fireback" - }, - "optionalDependencies": { - "@fireback/cli-darwin-x64": "0.0.12", - "@fireback/cli-darwin-arm64": "0.0.12", - "@fireback/cli-linux-x64": "0.0.12", - "@fireback/cli-win32-x64": "0.0.12" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "postinstall": "node ./scripts/install.js" - }, - "keywords": [ - "Fireback", - "Codegen", - "React", - "Angular" - ], - "author": "Ali Torabi", - "license": "ISC" -} \ No newline at end of file diff --git a/cmd/fireback-npm/cli/scripts/install.js b/cmd/fireback-npm/cli/scripts/install.js deleted file mode 100644 index 4abae0921..000000000 --- a/cmd/fireback-npm/cli/scripts/install.js +++ /dev/null @@ -1,361 +0,0 @@ -#!/usr/bin/env node - -"use strict"; - -const fs = require("fs"); -const os = require("os"); -const path = require("path"); -const crypto = require("crypto"); -const zlib = require("zlib"); -const stream = require("stream"); -const process = require("process"); - -const fetch = require("node-fetch"); -const HttpsProxyAgent = require("https-proxy-agent"); -const ProgressBar = require("progress"); -const Proxy = require("proxy-from-env"); -const which = require("which"); - -const helper = require("../js/helper"); -const pkgInfo = require("../package.json"); -const Logger = require("../js/logger"); - -const logger = new Logger(getLogStream("stderr")); - -const CDN_URL = - process.env.SENTRYCLI_LOCAL_CDNURL || - process.env.npm_config_sentrycli_cdnurl || - process.env.SENTRYCLI_CDNURL || - "https://downloads.sentry-cdn.com/sentry-cli"; - -function getLogStream(defaultStream) { - const logStream = process.env.SENTRYCLI_LOG_STREAM || defaultStream; - - if (logStream === "stdout") { - return process.stdout; - } - - if (logStream === "stderr") { - return process.stderr; - } - - throw new Error( - `Incorrect SENTRYCLI_LOG_STREAM env variable. Possible values: 'stdout' | 'stderr'` - ); -} - -function shouldRenderProgressBar() { - const silentFlag = process.argv.some((v) => v === "--silent"); - const silentConfig = process.env.npm_config_loglevel === "silent"; - const silentEnv = process.env.SENTRYCLI_NO_PROGRESS_BAR; - const ciEnv = process.env.CI === "true" || process.env.CI === "1"; - const notTTY = !process.stdout.isTTY; - // If any of possible options is set, skip rendering of progress bar - return !(silentFlag || silentConfig || silentEnv || ciEnv || notTTY); -} - -function getDownloadUrl(platform, arch) { - const releasesUrl = `${CDN_URL}/${pkgInfo.version}/sentry-cli`; - let archString = ""; - switch (arch) { - case "x64": - archString = "x86_64"; - break; - case "x86": - case "ia32": - archString = "i686"; - break; - case "arm64": - archString = "aarch64"; - break; - case "arm": - archString = "armv7"; - break; - default: - archString = arch; - } - switch (platform) { - case "darwin": - return `${releasesUrl}-Darwin-universal`; - case "win32": - // Windows arm machines can run x64 binaries - if (arch === "arm64") { - archString = "x86_64"; - } - return `${releasesUrl}-Windows-${archString}.exe`; - case "linux": - case "freebsd": - return `${releasesUrl}-Linux-${archString}`; - default: - return null; - } -} - -function createProgressBar(name, total) { - const incorrectTotal = typeof total !== "number" || Number.isNaN(total); - - if (incorrectTotal || !shouldRenderProgressBar()) { - return { - tick: () => {}, - }; - } - - const logStream = getLogStream("stdout"); - - if (logStream.isTTY) { - return new ProgressBar(`fetching ${name} :bar :percent :etas`, { - complete: "█", - incomplete: "░", - width: 20, - total, - }); - } - - let pct = null; - let current = 0; - return { - tick: (length) => { - current += length; - const next = Math.round((current / total) * 100); - if (next > pct) { - pct = next; - logStream.write(`fetching ${name} ${pct}%\n`); - } - }, - }; -} - -function npmCache() { - const keys = [ - "npm_config_cache", - "npm_config_cache_folder", - "npm_config_yarn_offline_mirror", - ]; - - for (let key of [...keys, ...keys.map((k) => k.toUpperCase())]) { - if (process.env[key]) return process.env[key]; - } - - if (process.env.APPDATA) { - return path.join(process.env.APPDATA, "npm-cache"); - } - - return path.join(os.homedir(), ".npm"); -} - -function getCachedPath(url) { - const digest = crypto.createHash("md5").update(url).digest("hex").slice(0, 6); - - return path.join( - npmCache(), - "sentry-cli", - `${digest}-${path.basename(url).replace(/[^a-zA-Z0-9.]+/g, "-")}` - ); -} - -function getTempFile(cached) { - return `${cached}.${process.pid}-${Math.random().toString(16).slice(2)}.tmp`; -} - -function validateChecksum(tempPath, name) { - let storedHash; - try { - const checksums = fs.readFileSync( - path.join(__dirname, "../checksums.txt"), - "utf8" - ); - const entries = checksums.split("\n"); - for (let i = 0; i < entries.length; i++) { - const [key, value] = entries[i].split("="); - if (key === name) { - storedHash = value; - break; - } - } - } catch (e) { - logger.log( - "Checksums are generated when the package is published to npm. They are not available directly in the source repository. Skipping validation." - ); - return; - } - - if (!storedHash) { - logger.log(`Checksum for ${name} not found, skipping validation.`); - return; - } - - const currentHash = crypto - .createHash("sha256") - .update(fs.readFileSync(tempPath)) - .digest("hex"); - - if (storedHash !== currentHash) { - fs.unlinkSync(tempPath); - throw new Error( - `Checksum validation for ${name} failed.\nExpected: ${storedHash}\nReceived: ${currentHash}` - ); - } else { - logger.log("Checksum validation passed."); - } -} - -async function downloadBinary() { - const arch = os.arch(); - const platform = os.platform(); - const outputPath = helper.getFallbackBinaryPath(); - - if (process.env.SENTRYCLI_USE_LOCAL === "1") { - try { - const binPaths = which.sync("sentry-cli", { all: true }); - if (!binPaths.length) throw new Error("Binary not found"); - const binPath = binPaths[binPaths.length - 1]; - logger.log(`Using local binary: ${binPath}`); - fs.copyFileSync(binPath, outputPath); - return Promise.resolve(); - } catch (e) { - throw new Error( - "Configured installation of local binary, but it was not found." + - "Make sure that `sentry-cli` executable is available in your $PATH or disable SENTRYCLI_USE_LOCAL env variable." - ); - } - } - - const downloadUrl = getDownloadUrl(platform, arch); - if (!downloadUrl) { - throw new Error(`Unsupported target ${platform}-${arch}`); - } - - const cachedPath = getCachedPath(downloadUrl); - if (fs.existsSync(cachedPath)) { - logger.log(`Using cached binary: ${cachedPath}`); - fs.copyFileSync(cachedPath, outputPath); - return; - } - - const proxyUrl = Proxy.getProxyForUrl(downloadUrl); - const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : null; - - logger.log(`Downloading from ${downloadUrl}`); - - if (proxyUrl) { - logger.log(`Using proxy URL: ${proxyUrl}`); - } - - let response; - try { - response = await fetch(downloadUrl, { - agent, - compress: false, - headers: { - "accept-encoding": "gzip, deflate, br", - }, - redirect: "follow", - }); - } catch (error) { - let errorMsg = `Unable to download sentry-cli binary from ${downloadUrl}.\nError message: ${error.message}`; - if (error.code) { - errorMsg += `\nError code: ${error.code}`; - } - throw new Error(errorMsg); - } - - if (!response.ok) { - let errorMsg = `Unable to download sentry-cli binary from ${downloadUrl}.\nServer returned: ${response.status}`; - if (response.statusText) { - errorMsg += ` - ${response.statusText}`; - } - throw new Error(errorMsg); - } - - const contentEncoding = response.headers.get("content-encoding"); - let decompressor; - if (/\bgzip\b/.test(contentEncoding)) { - decompressor = zlib.createGunzip(); - } else if (/\bdeflate\b/.test(contentEncoding)) { - decompressor = zlib.createInflate(); - } else if (/\bbr\b/.test(contentEncoding)) { - decompressor = zlib.createBrotliDecompress(); - } else { - decompressor = new stream.PassThrough(); - } - const name = downloadUrl.match(/.*\/(.*?)$/)[1]; - let downloadedBytes = 0; - const totalBytes = parseInt(response.headers.get("content-length"), 10); - const progressBar = createProgressBar(name, totalBytes); - const tempPath = getTempFile(cachedPath); - fs.mkdirSync(path.dirname(tempPath), { recursive: true }); - - await new Promise((resolve, reject) => { - response.body - .on("error", (e) => reject(e)) - .on("data", (chunk) => { - downloadedBytes += chunk.length; - progressBar.tick(chunk.length); - }) - .pipe(decompressor) - .pipe(fs.createWriteStream(tempPath, { mode: "0755" })) - .on("error", (e) => reject(e)) - .on("close", () => { - if (downloadedBytes >= totalBytes) { - resolve(); - } else { - reject(new Error("connection interrupted")); - } - }); - }); - - if (process.env.SENTRYCLI_SKIP_CHECKSUM_VALIDATION !== "1") { - validateChecksum(tempPath, name); - } - - fs.copyFileSync(tempPath, cachedPath); - fs.copyFileSync(tempPath, outputPath); - fs.unlinkSync(tempPath); -} - -async function checkVersion() { - const output = await helper.execute(["--version"]); - const version = output.replace("sentry-cli ", "").trim(); - const expected = pkgInfo.version; - if (version !== expected) { - throw new Error( - `Unexpected sentry-cli version "${version}", expected "${expected}"` - ); - } -} - -if (process.env.SENTRYCLI_SKIP_DOWNLOAD === "1") { - logger.log(`Skipping download because SENTRYCLI_SKIP_DOWNLOAD=1 detected.`); - process.exit(0); -} - -const { packageName: distributionPackageName, subpath: distributionSubpath } = - helper.getDistributionForThisPlatform(); - -if (distributionPackageName === undefined) { - helper.throwUnsupportedPlatformError(); -} - -try { - require.resolve(`${distributionPackageName}/${distributionSubpath}`); - // If the `resolve` call succeeds it means a binary was installed successfully via optional dependencies so we can skip the manual postinstall download. - process.exit(0); -} catch (e) { - // Optional dependencies likely didn't get installed - proceed with fallback downloading manually - // Log message inspired by esbuild: https://github.com/evanw/esbuild/blob/914f6080c77cfe32a54888caa51ca6ea13873ce9/lib/npm/node-install.ts#L253 - logger.log( - `Sentry CLI failed to locate the "${distributionPackageName}" package after installation! - -This can happen if you use an option to disable optional dependencies during installation, like "--no-optional", "--ignore-optional", or "--omit=optional". Sentry CLI uses the "optionalDependencies" package.json feature to install the correct binary for your platform and operating system. This post-install script will now try to work around this by manually downloading the Sentry CLI binary from the Sentry CDN. If this fails, you need to remove the "--no-optional", "--ignore-optional", and "--omit=optional" flags for Sentry CLI to work.` - ); - - downloadBinary() - .then(() => checkVersion()) - .then(() => { - process.exit(0); - }) - .catch((e) => { - console.error(e); - process.exit(1); - }); -} diff --git a/cmd/fireback/Makefile b/cmd/fireback/Makefile index e5bb9d914..b4479c346 100644 --- a/cmd/fireback/Makefile +++ b/cmd/fireback/Makefile @@ -84,18 +84,5 @@ pkg: npm: make npmc npmp -npmc: - cp ../../artifacts/$(project)-server-all/$(project)_amd64_darwin ../fireback-npm/cli-darwin-x64/bin/fireback && \ - cp ../../artifacts/$(project)-server-all/$(project)_arm64_darwin ../fireback-npm/cli-darwin-arm64/bin/fireback && \ - cp ../../artifacts/$(project)-server-all/$(project)_amd64_linux ../fireback-npm/cli-linux-x64/bin/fireback && \ - cp ../../artifacts/$(project)-server-all/$(project)_amd64_windows.exe ../fireback-npm/cli-win32-x64/bin/fireback.exe - -npmp: - cd ../fireback-npm/cli && npm publish && cd - && \ - cd ../fireback-npm/cli-darwin-x64 && npm publish && cd - && \ - cd ../fireback-npm/cli-darwin-arm64 && npm publish && cd - && \ - cd ../fireback-npm/cli-linux-x64 && npm publish && cd - && \ - cd ../fireback-npm/cli-win32-x64 && npm publish - clean: rm -rf ../../artifacts/$(project)-server-all && mkdir -p ../../artifacts/$(project)-server-all \ No newline at end of file diff --git a/modules/fireback/CrudCoreActions.go b/modules/fireback/CrudCoreActions.go index 65a78688b..75f973034 100644 --- a/modules/fireback/CrudCoreActions.go +++ b/modules/fireback/CrudCoreActions.go @@ -69,10 +69,6 @@ func ListGormSubEntities(entity reflect.Value) []string { continue } - if t == "fireback.String" || t == "String" { - continue - } - if t == "fireback.Duration" || t == "Duration" { continue } @@ -88,21 +84,7 @@ func ListGormSubEntities(entity reflect.Value) []string { if t == "*fireback.XDateTime" || t == "*XDateTime" { continue } - if t == "fireback.Int64" || t == "Int64" { - continue - } - if t == "fireback.Int32" || t == "Int32" { - continue - } - if t == "fireback.Float64" || t == "Float64" { - continue - } - if t == "fireback.Float32" || t == "Float32" { - continue - } - if t == "fireback.Bool" || t == "Bool" { - continue - } + if t == "fireback.JSON" || t == "JSON" { continue }