diff --git a/.github/workflows/binary-build.yml b/.github/workflows/binary-build.yml deleted file mode 100644 index 5d6b501..0000000 --- a/.github/workflows/binary-build.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Binary build - -# Push tests pushes -on: [ push ] - -defaults: - run: - shell: bash - -jobs: - - # Test the build - build: - # Setup - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ windows-latest, ubuntu-latest, macOS-latest, self-hosted ] - - # Go - steps: - - name: Check out repo - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Env - run: | - echo "Event name: ${{ github.event_name }}" - echo "Git ref: ${{ github.ref }}" - echo "GH actor: ${{ github.actor }}" - echo "SHA: ${{ github.sha }}" - VER=`node --version`; echo "Node ver: $VER" - VER=`npm --version`; echo "npm ver: $VER" - - - name: Install Globals - run: npm install -g @enhance/arc-plugin-enhance - - - name: Install - run: npm install - - - name: Build - run: npm run build - env: - BUILD_ALL: false - - - name: Test - run: npm run test:integration - env: - BINARY_ONLY: true - CI: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6b8045..5d881b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: node-version: [ 16.x, 18.x, 20.x ] - os: [ windows-latest, ubuntu-latest, macOS-latest, self-hosted ] + os: [ windows-latest, ubuntu-latest, macOS-latest ] # Go steps: @@ -75,93 +75,3 @@ jobs: run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - # Publish the build to S3 - publish: - # Setup - # needs: test - if: startsWith(github.ref, 'refs/tags/v') || - github.ref == 'refs/heads/main' - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest, self-hosted ] - - # Go - steps: - - name: Check out repo - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install aws-sdk - run: npm i aws-sdk - - - name: Install - run: npm i - - - name: Publish 'latest' (aka production) build - if: startsWith(github.ref, 'refs/tags/v') - run: npm run publish-binary - env: - DEPLOY: prod - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - BEGIN_CLI_CLIENT_ID_STAGING: ${{ secrets.BEGIN_CLI_CLIENT_ID_STAGING }} - BEGIN_CLI_CLIENT_ID_PRODUCTION: ${{ secrets.BEGIN_CLI_CLIENT_ID_PRODUCTION }} - S3_BUCKET: ${{ secrets.S3_BUCKET }} - - - name: Publish 'main' (aka canary) build - if: github.ref == 'refs/heads/main' - run: npm run publish-binary - env: - DEPLOY: main - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - BEGIN_CLI_CLIENT_ID_STAGING: ${{ secrets.BEGIN_CLI_CLIENT_ID_STAGING }} - BEGIN_CLI_CLIENT_ID_PRODUCTION: ${{ secrets.BEGIN_CLI_CLIENT_ID_PRODUCTION }} - S3_BUCKET: ${{ secrets.S3_BUCKET }} - - # Deploy to the API + CDN - deploy: - # Setup - needs: publish - if: startsWith(github.ref, 'refs/tags/v') || - github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - - # Go - steps: - - name: Check out repo - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Install - run: npm i aws-sdk - - - name: Deploy 'latest' (aka production) build - if: startsWith(github.ref, 'refs/tags/v') - run: npm run deploy - env: - DEPLOY: prod - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CF_DISTRO: ${{ secrets.CF_DISTRO }} - LATEST_API: ${{ secrets.LATEST_API }} - - - name: Deploy 'main' (aka canary) build - if: github.ref == 'refs/heads/main' - run: npm run deploy - env: - DEPLOY: main - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - CF_DISTRO: ${{ secrets.CF_DISTRO }} - LATEST_API: ${{ secrets.LATEST_API }} diff --git a/.gitignore b/.gitignore index 517955e..373db0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,6 @@ +node_modules/ .nyc_output/ -build -commit -client-ids.json -config.json coverage/ -node_modules/ + scratch/ -scripts/package.json test/tmp/ diff --git a/package.json b/package.json index 223f8f7..80099b3 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "@begin/deploy", + "license": "Apache-2.0", "version": "0.21.6", "bin": { "begin": "src/index.js" @@ -13,14 +14,9 @@ "test:unit": "cross-env tape 'test/unit/**/*-test.js' | tap-arc -v", "test:integration": "cross-env NODE_ENV=testing tape 'test/integration/**/*-test.js' | tap-arc -v", "test:integration:slow": "cross-env NODE_ENV=testing tape 'test/integration/**/*-test-slow.js' | tap-arc -v", - "test:module": "cross-env MODULE_ONLY=true npm run test", "coverage": "nyc --reporter=lcov --reporter=text npm run test:unit", - "lint": "eslint . --fix", - "build": "node vendor/vendor.js && cross-env scripts/binary-config && npx pkg scripts --compress GZip && rm -f commit", - "publish-binary": "BUILD_ALL=true npm run build && scripts/publish", - "deploy": "scripts/deploy" + "lint": "eslint . --fix" }, - "license": "Apache-2.0", "dependencies": { "@architect/inventory": "4.0.4", "@architect/parser": "6.0.3", @@ -29,7 +25,6 @@ "@colors/colors": "1.6.0", "@enhance/cli": "1.2.0", "@enhance/starter-project": "7.0.2", - "adm-zip": "0.5.10", "enquirer": "2.4.1", "minimist": "1.2.8", "node-machine-id": "1.1.12", @@ -37,16 +32,16 @@ "strip-ansi": "6.0.1", "tiny-json-http": "7.5.1", "tmp": "0.2.3", + "update-notifier-cjs": "5.1.6", "ws": "8.16.0" }, "devDependencies": { - "@architect/eslint-config": "~2.1.2", + "@architect/eslint-config": "3.0.0-RC.0", "@architect/plugin-node-prune": "2.1.0-RC.0", "cross-env": "~7.0.3", "eslint": "~8.57.0", "fs-extra": "~11.2.0", "nyc": "~15.1.0", - "pkg": "5.8.1", "proxyquire": "~2.1.3", "string-argv": "~0.3.2", "tap-arc": "~1.2.2", diff --git a/readme.md b/readme.md index b92afaf..5142c7d 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,7 @@ Alternatively, you can install Begin with npm: `npm i -g @begin/cli`. ## Running locally -Before running `npm run build` to create a local binary be sure to set the following environment variables: +Be sure to set the following environment variables: ``` export DEPLOY=main @@ -83,6 +83,6 @@ Similarly, to switch back to `latest` from `main`, run: `begin update --use late Wherever possible, the Begin CLI adheres to the [Command Line Interface Guidelines](https://clig.dev/). -Begin is `async/await` / `Promises`-based, and uses `pkg` for binary compilation. It is currently CommonJS, with plans to [eventually refactor to ESM](https://github.com/vercel/pkg/issues/1291). +Begin is `async/await` / `Promises`-based. It is currently CommonJS, with plans to eventually refactor to ESM. Begin is written in idiomatic JavaScript with a key exception: each command's specific `require()` statements are in local scope, not global. This is specifically and deliberately done to [reduce the coldstart time and ensure every execution runs as fast as possible](https://github.com/beginner-corp/cli/discussions/4). diff --git a/scripts/binary-config b/scripts/binary-config deleted file mode 100755 index 89ca0f7..0000000 --- a/scripts/binary-config +++ /dev/null @@ -1,113 +0,0 @@ -#! /usr/bin/env node -let { existsSync, writeFileSync } = require('fs') -let { execSync } = require('child_process') -let { join } = require('path') -let { prune } = require('@architect/plugin-node-prune') -let { DEPLOY, BUILD_ALL } = process.env -let os = process.platform -let arch = process.arch -console.log(`Building Begin... (DEPLOY: ${DEPLOY}, BUILD_ALL: ${BUILD_ALL})`) - -/** - * Node versions: `node14`, `node16`, or latest - * Platforms: `alpine`, `linux`, `linuxstatic`, `win`, `macos` - * Architectures: `x64`, `arm64` - */ -let config = { - name: 'begin', - bin: { - cli: '../src/pkg-index.js' - }, - pkg: { - // Don't manually include runtimes/deno.js in scripts, as it fails on pkg#997 - scripts: [ - // Begin stuff - // Some commands have dynamically required subcommands, so just grab everything - '../src/commands/**/*.js', - // Enhance CLI - '../node_modules/@enhance/cli/**/*.js', - // Arc stuff - '../node_modules/@architect/inventory/**/*.js', - '../node_modules/dynalite/**/*.js', - ], - assets: [ - '../node_modules/@architect/sandbox/src/invoke-lambda/exec/runtimes/*', - '../node_modules/@architect/sandbox/src/tables/_aws-lite-dynamodb-vendor.js', - '../package.json', - // Enhance stuff - '../node_modules/@enhance/starter-project/**/*', - ], - targets: [], - outputPath: 'build', - } -} - -// Main version is derived from the latest git commit -if (DEPLOY === 'main') { - let cmd = 'git rev-parse HEAD' - let result = execSync(cmd) - if (!result) { - throw ReferenceError('Missing build sha') - } - let sha = result.toString().substr(0, 7) - let appVersion = `main-${sha}` - let commitFile = join(__dirname, '..', 'commit') - writeFileSync(commitFile, appVersion) - config.bin.cli = '../src/_main.js' - config.pkg.assets.push('../commit') -} - -// Handle client IDs in main or prod (and optionally locally) -// However, client IDs should not be required for local testing -let clientIDFile = join(__dirname, '..', 'client-ids.json') -if (DEPLOY) { - let staging = process.env.BEGIN_CLI_CLIENT_ID_STAGING - let production = process.env.BEGIN_CLI_CLIENT_ID_PRODUCTION - if (!staging || !production) { - throw ReferenceError('Missing staging and/or production client ID') - } - let clientIDs = JSON.stringify({ staging, production }) - writeFileSync(clientIDFile, clientIDs) -} -if (existsSync(clientIDFile)) { - config.pkg.assets.push('../client-ids.json') -} - -let nodeVer = `node18` -let platforms = { - darwin_x64: `${nodeVer}-macos-x64`, - darwin_arm64: `${nodeVer}-macos-arm64`, - linux: `${nodeVer}-linux-x64`, // TODO arm64 - win32: `${nodeVer}-win-x64`, -} - -if (BUILD_ALL === 'true') { - // The self-hosted GHA Runner is currently only responsible for macOS arm64 builds - if (os === 'darwin' && arch === 'arm64') { - config.pkg.targets.push( - platforms.darwin_arm64 - ) - } - // Everything else can be reliably built from Linux - else { - config.pkg.targets.push( - platforms.darwin_x64, - platforms.linux, - platforms.win32, - ) - } -} -else { - // In theory we could use the 'host' alias, but the Node.js version won't be pinned to 14 - let target = os === 'darwin' ? platforms[`darwin_${arch}`] : platforms[os] - config.pkg.targets.push(target) -} - -let path = join(__dirname, 'package.json') -writeFileSync(path, JSON.stringify(config, null, 2)) - -// Tidy up node_modules before compiling! -console.log('Pruning junk from project node_modules:') -process.env.ARC_PRUNE_IGNORE_CUSTOM = '-not -path *istanbul*' -prune(join(__dirname, '..')) -delete process.env.ARC_PRUNE_IGNORE_CUSTOM diff --git a/scripts/deploy b/scripts/deploy deleted file mode 100755 index 661481c..0000000 --- a/scripts/deploy +++ /dev/null @@ -1,73 +0,0 @@ -#! /usr/bin/env node -let aws = require('aws-sdk') -let { getVersion, region } = require('./lib') - -let { DEPLOY, CF_DISTRO: DistributionId, LATEST_API: FunctionName } = process.env -if (!DEPLOY) throw ReferenceError('Missing DEPLOY config!') -if (!DistributionId) throw ReferenceError('Missing CF_DISTRO config!') -if (!FunctionName) throw ReferenceError('Missing LATEST_API config!') -let valid = [ 'prod', 'main' ] -if (!valid.includes(DEPLOY)) throw ReferenceError(`DEPLOY must be one of: ${valid.join(', ')}`) - -let cf = new aws.CloudFront() -let lambda = new aws.Lambda({ region }) -let ssm = new aws.SSM({ region }) - -;(async () => { - try { - let isProd = DEPLOY === 'prod' - let version = await getVersion() - let channel = isProd ? 'latest' : 'main' - - // Flush CDN release channel - let releasePath = `/releases/${channel}/*` - await cf.createInvalidation({ - DistributionId, - InvalidationBatch: { - CallerReference: `${channel}-${new Date().toISOString()}`, - Paths: { Quantity: 1, Items: [ releasePath ] } - } - }).promise() - console.log(`Invalidated ${releasePath}`) - - let uri = ext => `https://dl.begin.com/releases/${channel}/begin-${ext}` - let data = { - [`ver_${channel}`.toUpperCase()]: version, - [`releases_${channel}`.toUpperCase()]: JSON.stringify({ - darwin: { - arm64: uri('arm64-darwin.zip'), - x64: uri('x64-darwin.zip'), - }, - linux: { - arm64: null, - x64: uri('x64-linux.zip'), - }, - windows: { - arm64: null, - x64: uri('x64-windows.zip'), - } - }) - } - for (let [ key, Value ] of Object.entries(data)) { - // Update env vars - let params = { - Name: `/begin-install/production/${key}`, - Value, - Type: 'SecureString', - Overwrite: true - } - await ssm.putParameter(params).promise() - console.log(`Updated ${key}`) - } - - // Update `dl.begin.com/versions` config - let config = await lambda.getFunctionConfiguration({ FunctionName }).promise() - let Environment = { Variables: { ...config.Environment.Variables, ...data } } - await lambda.updateFunctionConfiguration({ FunctionName, Environment }).promise() - console.log(`Updated dl.begin.com/latest`) - } - catch (err) { - console.log('Deploy failed!', err) - process.exit(1) - } -})() diff --git a/scripts/lib/index.js b/scripts/lib/index.js deleted file mode 100644 index 73e0af6..0000000 --- a/scripts/lib/index.js +++ /dev/null @@ -1,31 +0,0 @@ -let { join } = require('path') -let { readFile } = require('fs/promises') -let { execSync } = require('child_process') - -let region = 'us-west-2' - -async function getVersion () { - let { DEPLOY } = process.env - let isProd = DEPLOY === 'prod' - - if (isProd) { - let pkg = join(__dirname, '..', '..', 'package.json') - let version = JSON.parse(await readFile(pkg)).version - if (!version.match(/^\d+.\d+.\d+$/)) { - let msg = `Only production major, minor, or patch releases can be shipped (got: ${version})` - throw ReferenceError(msg) - } - return version - } - else { - let cmd = 'git rev-parse HEAD' - let sha = execSync(cmd) - let version = `main-${sha.toString().substr(0, 7)}` - return version - } -} - -module.exports = { - getVersion, - region, -} diff --git a/scripts/publish b/scripts/publish deleted file mode 100755 index d4b1503..0000000 --- a/scripts/publish +++ /dev/null @@ -1,69 +0,0 @@ -#! /usr/bin/env node -let { existsSync } = require('fs') -let { readFile } = require('fs/promises') -let { join } = require('path') -let admZip = require('adm-zip') -let aws = require('aws-sdk') -let { getVersion, region } = require('./lib') - -let { DEPLOY, S3_BUCKET: Bucket } = process.env -if (!Bucket) throw ReferenceError('Missing S3_BUCKET config!') -if (!DEPLOY) throw ReferenceError('Missing DEPLOY config!') -let valid = [ 'prod', 'main' ] -if (!valid.includes(DEPLOY)) throw ReferenceError(`DEPLOY must be one of: ${valid.join(', ')}`) - -let s3 = new aws.S3({ region }) -let kb = buf => Math.floor(buf.length / 1000) - -;(async () => { - try { - let isProd = DEPLOY === 'prod' - let isMacARM = process.platform === 'darwin' && process.arch === 'arm64' - let version = await getVersion() - - console.log(`Deploying Begin... (version: ${version}, DEPLOY: ${DEPLOY})`) - let name = 'begin' - let files = { - 'begin-linux': { name, zip: 'begin-x64-linux.zip' }, - 'begin-macos': { name, zip: 'begin-x64-darwin.zip' }, - 'begin-win.exe': { name: 'b.exe', zip: 'begin-x64-windows.zip' }, - - // Coming soon: - // 'begin-linux-x64': { name, zip: 'begin-x64-linux.zip' }, - // 'begin-win-x64.exe': { name: 'begin.exe', zip: 'begin-x64-windows.zip' }, - } - if (isMacARM) { - files = { 'begin': { name, zip: 'begin-arm64-darwin.zip' } } - } - - let channel = isProd ? 'latest' : 'main' - let ACL = 'public-read' - let CacheControl = 's-maxage=3600, max-age=3600, must-revalidate' // 1 hour - - for (let [ local, { name, zip } ] of Object.entries(files)) { - let path = join(__dirname, '..', 'build', local) - if (existsSync(path)) { - let Zip = new admZip() - let buf = await readFile(path) - Zip.addFile(name, buf) - let Body = Zip.toBuffer() - let Key = `releases/${channel}/${zip}` - - console.log(`Loaded ${path}: ${kb(buf)} KB uncompresed`) - await s3.putObject({ ACL, Body, Bucket, Key, CacheControl }).promise() - console.log(`Uploaded ${path} to ${Key} (${kb(Body)} KB compressed)`) - - if (isProd) { - let CopySource = `${Bucket}/releases/${channel}/${zip}` - let Key = `releases/${version}/${zip}` - await s3.copyObject({ ACL, CopySource, Key, Bucket }).promise() - console.log(`Copied ${CopySource} to ${Key}`) - } - } - } - } - catch (err) { - console.log('Publish failed!', err) - process.exit(1) - } -})() diff --git a/src/commands/builds/errors.js b/src/commands/builds/errors.js index b3185ae..3bc19e6 100644 --- a/src/commands/builds/errors.js +++ b/src/commands/builds/errors.js @@ -6,7 +6,7 @@ module.exports = function error (params) { app_not_found: 'No app found with that app ID', no_env: 'Environment ID not found, please run with -e or --env', invalid_env: 'Invalid or incorrect environment ID', - } + }, } return Error(errors[lang][err]) } diff --git a/src/commands/builds/help.js b/src/commands/builds/help.js index c6d817a..153700c 100644 --- a/src/commands/builds/help.js +++ b/src/commands/builds/help.js @@ -21,6 +21,6 @@ module.exports = { name: 'List builds', example: 'begin builds --env ', }, - ] - } + ], + }, } diff --git a/src/commands/builds/index.js b/src/commands/builds/index.js index 8730831..e29257c 100644 --- a/src/commands/builds/index.js +++ b/src/commands/builds/index.js @@ -81,7 +81,7 @@ async function action (params) { let prompt = new Select({ name: 'build', message: 'View detailed build logs? (ctrl-c to skip)', - choices + choices, }, promptOptions) let answer = await prompt.run() diff --git a/src/commands/create/action.js b/src/commands/create/action.js index b836429..5729f44 100644 --- a/src/commands/create/action.js +++ b/src/commands/create/action.js @@ -53,7 +53,7 @@ module.exports = async function action (params, utils) { name: 'name', message: 'What would you like to name your new environment?', initial, - validate: validateEnvName.prompt + validate: validateEnvName.prompt, }, promptOptions) envName = name } diff --git a/src/commands/create/help.js b/src/commands/create/help.js index ca5104a..490451e 100644 --- a/src/commands/create/help.js +++ b/src/commands/create/help.js @@ -31,6 +31,6 @@ module.exports = { name: `Create an app environment named 'staging'`, example: 'begin create --env staging', }, - ] - } + ], + }, } diff --git a/src/commands/create/index.js b/src/commands/create/index.js index f3f2e35..f8bd293 100644 --- a/src/commands/create/index.js +++ b/src/commands/create/index.js @@ -28,7 +28,7 @@ async function action (params) { // Pass along any specified environment IDs let env = args.env || args.e - let envName = env !== true && env || undefined + let envName = (env !== true && env) || undefined let utils = { ...lib, @@ -38,7 +38,7 @@ async function action (params) { appID, envName, config, - ...params + ...params, }, utils) } diff --git a/src/commands/deploy/help.js b/src/commands/deploy/help.js index ddb7281..946b1e4 100644 --- a/src/commands/deploy/help.js +++ b/src/commands/deploy/help.js @@ -26,6 +26,6 @@ module.exports = { name: `Deploy the app environment named 'staging'`, example: 'begin deploy --env staging', }, - ] - } + ], + }, } diff --git a/src/commands/deploy/index.js b/src/commands/deploy/index.js index 4fc1cb1..b6464ac 100644 --- a/src/commands/deploy/index.js +++ b/src/commands/deploy/index.js @@ -28,7 +28,7 @@ async function action (params) { // Pass along any specified environment IDs let env = args.env || args.e - let envName = env !== true && env || undefined + let envName = (env !== true && env) || undefined let utils = { ...lib, @@ -38,7 +38,7 @@ async function action (params) { appID, envName, config, - ...params + ...params, }, utils) } diff --git a/src/commands/destroy/help.js b/src/commands/destroy/help.js index edb2ee4..7452a07 100644 --- a/src/commands/destroy/help.js +++ b/src/commands/destroy/help.js @@ -7,7 +7,7 @@ module.exports = { items: [ { name: '-a, --app ', - description: `If used without the \`env\` flag: destroy an app and all its environments. If used with the \`env\` flag: destroy a single app environment` + description: `If used without the \`env\` flag: destroy an app and all its environments. If used with the \`env\` flag: destroy a single app environment`, }, { name: '-e, --env [name|ID]', @@ -30,6 +30,6 @@ module.exports = { name: `Destroy the app environment named 'staging'`, example: 'begin destroy --env staging', }, - ] - } + ], + }, } diff --git a/src/commands/destroy/index.js b/src/commands/destroy/index.js index b82c895..8179f91 100644 --- a/src/commands/destroy/index.js +++ b/src/commands/destroy/index.js @@ -28,7 +28,7 @@ async function action (params) { appID, env, config, - ...params + ...params, }, utils) } diff --git a/src/commands/dev/help.js b/src/commands/dev/help.js index 8d90be5..f10e8ce 100644 --- a/src/commands/dev/help.js +++ b/src/commands/dev/help.js @@ -37,5 +37,5 @@ module.exports = { example: 'begin dev --port 6666', }, ], - } + }, } diff --git a/src/commands/domains/help.js b/src/commands/domains/help.js index 3c89647..357c11c 100644 --- a/src/commands/domains/help.js +++ b/src/commands/domains/help.js @@ -137,7 +137,7 @@ const HELP = { header: 'Unlink parameters', items: [ { name: '--domain', description: 'Domain name to unlink', optional: true }, - { name: '-y, --yes', description: 'Skip confirmation prompt', optional: true } + { name: '-y, --yes', description: 'Skip confirmation prompt', optional: true }, ], }, examples: [ @@ -179,5 +179,5 @@ const HELP = { }, ], }, - } + }, } diff --git a/src/commands/domains/link.js b/src/commands/domains/link.js index 149e61e..bf602d2 100644 --- a/src/commands/domains/link.js +++ b/src/commands/domains/link.js @@ -13,7 +13,7 @@ async function action (params) { if (!domains.length) return Error('No domains found. Start by running: begin domains add --domain ') - if (!domainName || (typeof domainName === 'string' && domainName.length === 0)){ + if (!domainName || (typeof domainName === 'string' && domainName.length === 0)) { const prompt = new Select({ name: 'domain', message: 'Select a domain', @@ -94,7 +94,7 @@ async function action (params) { else return message.join('\n') } - if (!appID || (typeof appID === 'string' && appID.length === 0)){ + if (!appID || (typeof appID === 'string' && appID.length === 0)) { spinner('Fetching apps') const apps = await client.list({ _staging, token }) spinner.done() @@ -113,7 +113,7 @@ async function action (params) { if (!theApp) return Error(`Unable to find App with id <${appID}>`) - if (!env || (typeof env === 'string' && env.length === 0)){ + if (!env || (typeof env === 'string' && env.length === 0)) { const prompt = new Select({ name: 'env', message: 'Select an environment', @@ -127,7 +127,7 @@ async function action (params) { if (!theEnv) return Error(`App <${appID}> does not have an environment "${env}"`) - if (!yes){ + if (!yes) { const prompt = new Confirm({ name: 'confirm', message: `Link ${fDomain} to ${f.app.name(theApp.name)}'s "${f.env.name(theEnv.name)}" env?`, diff --git a/src/commands/domains/list.js b/src/commands/domains/list.js index 262799c..97fc558 100644 --- a/src/commands/domains/list.js +++ b/src/commands/domains/list.js @@ -26,7 +26,7 @@ async function action (params) { if (verbose) row.push(`${domainTitle} ${f.ID(domainID)}`) else row.push(domainTitle) - if (verbose ){ + if (verbose ) { row.push(`\n Updated: ${f.date(updatedAt)}`) row.push(`\n Status: ${status} `) } diff --git a/src/commands/domains/records.js b/src/commands/domains/records.js index 0a1454d..e89e69e 100644 --- a/src/commands/domains/records.js +++ b/src/commands/domains/records.js @@ -126,7 +126,7 @@ async function action (params) { } else { const rows = [ `Records for ${c.underline(c.cyan(domain))}`, '' ] - for (const r of outputRecords){ + for (const r of outputRecords) { const row = [ ' ', c.bold(r.type), @@ -135,7 +135,7 @@ async function action (params) { '\n ', r.values?.join('\n'), ] - if (verbose) row.push('\n ', 'TTL: ', r.ttl,) + if (verbose) row.push('\n ', 'TTL: ', r.ttl) rows.push(row.join('')) } diff --git a/src/commands/domains/unlink.js b/src/commands/domains/unlink.js index 9bbd70b..1d66dea 100644 --- a/src/commands/domains/unlink.js +++ b/src/commands/domains/unlink.js @@ -9,7 +9,7 @@ async function action (params) { const domains = await client.domains.list({ _staging, token }) - if (!domain || (typeof domain === 'string' && domain.length === 0)){ + if (!domain || (typeof domain === 'string' && domain.length === 0)) { const prompt = new Select({ name: 'domain', message: 'Select a domain to unlink', @@ -36,7 +36,7 @@ async function action (params) { if (!theEnv) return Error(`App <${appLink.appID}> does not have an environment "${appLink.envID}"`) - if (!yes){ + if (!yes) { const prompt = new Confirm({ name: 'confirm', message: `Unlink ${c.underline(c.cyan(domain))} from ${c.bold(theApp.name)}'s "${theEnv.name}" env?`, diff --git a/src/commands/env/create/index.js b/src/commands/env/create/index.js index 7bfa555..0edd94b 100644 --- a/src/commands/env/create/index.js +++ b/src/commands/env/create/index.js @@ -36,7 +36,7 @@ module.exports = { name: "Create a variable named 'FOO' in 'staging' with special characters (Windows)", example: 'begin env create --env staging --name FOO --value "bar!"', }, - ] - } - } + ], + }, + }, } diff --git a/src/commands/env/destroy/index.js b/src/commands/env/destroy/index.js index 4146690..eba982e 100644 --- a/src/commands/env/destroy/index.js +++ b/src/commands/env/destroy/index.js @@ -24,7 +24,7 @@ module.exports = { name: `Delete a variable named 'foo' in 'staging'`, example: 'begin env destroy --env staging --name foo', }, - ] - } - } + ], + }, + }, } diff --git a/src/commands/env/errors.js b/src/commands/env/errors.js index ddeeac2..51d7585 100644 --- a/src/commands/env/errors.js +++ b/src/commands/env/errors.js @@ -11,7 +11,7 @@ module.exports = function error (params) { no_value: 'Variable value not found, please run with -v or --value', create_fail: 'Failed to create environment variable', destroy_fail: 'Failed to destroy environment variable', - } + }, } return Error(errors[lang][err]) } diff --git a/src/commands/env/help.js b/src/commands/env/help.js index ccd0a9a..d645b4c 100644 --- a/src/commands/env/help.js +++ b/src/commands/env/help.js @@ -9,7 +9,7 @@ let newEnv = () => ({ }, ], examples: [], - } + }, }) module.exports = async function generateHelp (subcommands, aliases, params) { diff --git a/src/commands/env/index.js b/src/commands/env/index.js index 0d108b6..198710e 100644 --- a/src/commands/env/index.js +++ b/src/commands/env/index.js @@ -54,7 +54,7 @@ async function action (params) { app, appID, config, - ...params + ...params, }, utils) } else { diff --git a/src/commands/env/list/index.js b/src/commands/env/list/index.js index 7e09bea..80a1990 100644 --- a/src/commands/env/list/index.js +++ b/src/commands/env/list/index.js @@ -20,7 +20,7 @@ module.exports = { name: 'List variables', example: 'begin env list', }, - ] - } - } + ], + }, + }, } diff --git a/src/commands/generate/generators/api/index.js b/src/commands/generate/generators/api/index.js index 5a160ff..200c844 100644 --- a/src/commands/generate/generators/api/index.js +++ b/src/commands/generate/generators/api/index.js @@ -21,9 +21,9 @@ module.exports = { { name: 'Create a new API route with path parameter', example: `begin gen api --path '/notes/$id'`, - } - ] - } + }, + ], + }, } - } + }, } diff --git a/src/commands/generate/generators/auth/index.js b/src/commands/generate/generators/auth/index.js index 9c9338e..5207af4 100644 --- a/src/commands/generate/generators/auth/index.js +++ b/src/commands/generate/generators/auth/index.js @@ -21,9 +21,9 @@ module.exports = { { name: 'Basic Usage', example: 'begin generate auth', - } - ] + }, + ], }, } - } + }, } diff --git a/src/commands/generate/generators/element/index.js b/src/commands/generate/generators/element/index.js index ff44371..3d0a13d 100644 --- a/src/commands/generate/generators/element/index.js +++ b/src/commands/generate/generators/element/index.js @@ -17,9 +17,9 @@ module.exports = { { name: 'Create an element', example: 'begin gen element --name my-element', - } - ] - } + }, + ], + }, } - } + }, } diff --git a/src/commands/generate/generators/event/index.js b/src/commands/generate/generators/event/index.js index 216c910..a60f74a 100644 --- a/src/commands/generate/generators/event/index.js +++ b/src/commands/generate/generators/event/index.js @@ -17,9 +17,9 @@ module.exports = { { name: 'Create a new async event', example: 'begin gen event --name my-event', - } - ] - } + }, + ], + }, } - } + }, } diff --git a/src/commands/generate/generators/http/index.js b/src/commands/generate/generators/http/index.js index 1ee0c62..f8288db 100644 --- a/src/commands/generate/generators/http/index.js +++ b/src/commands/generate/generators/http/index.js @@ -28,9 +28,9 @@ module.exports = { { name: 'Create a new HTTP route', example: 'begin gen http --method get --path /', - } - ] + }, + ], }, } - } + }, } diff --git a/src/commands/generate/generators/page/index.js b/src/commands/generate/generators/page/index.js index 9fb684a..3a15d03 100644 --- a/src/commands/generate/generators/page/index.js +++ b/src/commands/generate/generators/page/index.js @@ -26,9 +26,9 @@ module.exports = { { name: 'Create a new page route with path parameter', example: `begin gen page --path '/notes/$id'`, - } - ] - } + }, + ], + }, } - } + }, } diff --git a/src/commands/generate/generators/scaffold/index.js b/src/commands/generate/generators/scaffold/index.js index 59c6789..d7c1268 100644 --- a/src/commands/generate/generators/scaffold/index.js +++ b/src/commands/generate/generators/scaffold/index.js @@ -34,9 +34,9 @@ module.exports = { { name: 'Scaffold a CRUD app from JSON Schema file', example: 'begin generate scaffold --file person.schema.json', - } - ] + }, + ], }, } - } + }, } diff --git a/src/commands/generate/generators/scheduled/index.js b/src/commands/generate/generators/scheduled/index.js index 95adbe3..af5659c 100644 --- a/src/commands/generate/generators/scheduled/index.js +++ b/src/commands/generate/generators/scheduled/index.js @@ -41,8 +41,8 @@ module.exports = { { name: 'Create a new scheduled event that runs at 6:00 PM Monday through Friday', example: 'begin gen scheduled --name my-task --cron "0 18 ? * MON-FRI *"', - } - ] - } - } + }, + ], + }, + }, } diff --git a/src/commands/generate/help.js b/src/commands/generate/help.js index 9cf03a4..79923bf 100644 --- a/src/commands/generate/help.js +++ b/src/commands/generate/help.js @@ -9,7 +9,7 @@ let newHelp = () => ({ }, ], examples: [], - } + }, }) module.exports = async function generateHelp (subcommands, params) { diff --git a/src/commands/help/index.js b/src/commands/help/index.js index eabc18c..6d19983 100644 --- a/src/commands/help/index.js +++ b/src/commands/help/index.js @@ -114,7 +114,7 @@ let help = { example: 'begin help generate', }, ], - } + }, } module.exports = { diff --git a/src/commands/index.js b/src/commands/index.js index b2523e7..436e2a8 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -46,7 +46,7 @@ module.exports = async function runCommand (params) { ` args: ${JSON.stringify(args)}\n` + ` cmd: ${cmd}\n` + ` vers: node: ${vers.node}, v8: ${vers.v8}\n` + - ` term: tty: ${!!(isTTY)}, ${columns} cols, ${rows} rows, ci: ${isCI}` + ` term: tty: ${!!(isTTY)}, ${columns} cols, ${rows} rows, ci: ${isCI}`, ) let getHelp = async help => typeof help === 'function' ? help(params) : help diff --git a/src/commands/list/help.js b/src/commands/list/help.js index 8153198..b4b8623 100644 --- a/src/commands/list/help.js +++ b/src/commands/list/help.js @@ -7,6 +7,6 @@ module.exports = { name: `List all apps and environments`, example: 'begin list', }, - ] - } + ], + }, } diff --git a/src/commands/list/index.js b/src/commands/list/index.js index 78bdef0..f659b70 100644 --- a/src/commands/list/index.js +++ b/src/commands/list/index.js @@ -31,14 +31,14 @@ async function action (params) { c.dim(location), ] let linkedDomain = domains.find(({ appLink }) => - appLink?.appID === appID && appLink?.envID === envID + appLink?.appID === appID && appLink?.envID === envID, ) let appUrl = c.green.underline(url) envRow.push( linkedDomain ? `\n ├─ ${c.cyan.underline(`https://${linkedDomain.domain}`)}\n └─ ${appUrl}` - : `\n └─ ${appUrl}` + : `\n └─ ${appUrl}`, ) rows.push(envRow.join(' ')) diff --git a/src/commands/login/index.js b/src/commands/login/index.js index 0f3a996..c08d031 100644 --- a/src/commands/login/index.js +++ b/src/commands/login/index.js @@ -5,8 +5,8 @@ module.exports = { en: { usage: [ 'login' ], description: 'Log into Begin to create and administer your apps', - } - } + }, + }, } async function action (params) { @@ -62,7 +62,7 @@ async function action (params) { let { body } = await tiny.post({ url, headers, - data: { client_id: clientID } + data: { client_id: clientID }, }) let expired = Date.now() + (30 * 1000) // 30 minute TTL @@ -104,7 +104,7 @@ async function getAccessToken (params) { data: { client_id: clientID, device_code, - } + }, }) if (body.access_token) res(body.access_token) else throw ReferenceError('Expected access_token') diff --git a/src/commands/logout/index.js b/src/commands/logout/index.js index a9f5c64..01f8a53 100644 --- a/src/commands/logout/index.js +++ b/src/commands/logout/index.js @@ -5,8 +5,8 @@ module.exports = { en: { usage: [ 'logout' ], description: 'Log out of Begin and destroy the current access token', - } - } + }, + }, } async function action (params) { diff --git a/src/commands/logs/errors.js b/src/commands/logs/errors.js index 7b5fab4..fcb8b03 100644 --- a/src/commands/logs/errors.js +++ b/src/commands/logs/errors.js @@ -6,7 +6,7 @@ module.exports = function error (params) { app_not_found: 'No app found with that app ID', no_env: 'Environment ID not found, please run with -e or --envID', invalid_env: 'Invalid or incorrect environment ID', - } + }, } return Error(errors[lang][err]) } diff --git a/src/commands/logs/help.js b/src/commands/logs/help.js index 120aca2..1196448 100644 --- a/src/commands/logs/help.js +++ b/src/commands/logs/help.js @@ -38,6 +38,6 @@ module.exports = { name: 'List logs with filter', example: 'begin logs --env staging --filter "GOT HERE"', }, - ] - } + ], + }, } diff --git a/src/commands/new/action.js b/src/commands/new/action.js index 991afed..8ff5190 100644 --- a/src/commands/new/action.js +++ b/src/commands/new/action.js @@ -1,5 +1,5 @@ module.exports = async function (params) { - let { lstatSync, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync } = require('fs') + let { cpSync, existsSync, mkdirSync, readFileSync } = require('fs') let { isAbsolute, join, normalize } = require('path') let { args } = params @@ -40,7 +40,7 @@ module.exports = async function (params) { // Read package.json from starter project let packagePath = join(nodeModules, '@enhance', 'starter-project', 'package.json') - let packageJson = JSON.parse(readFileSync(packagePath)) + let packageJson = JSON.parse(readFileSync(packagePath).toString()) // Tweak settings for new project packageJson.name = appName @@ -63,29 +63,8 @@ module.exports = async function (params) { let appPath = join(nodeModules, '@enhance', 'starter-project', 'app') let publicPath = join(nodeModules, '@enhance', 'starter-project', 'public') - /* pkg workaround */ - function copyFolderSync (from, to) { - mkdirSync(to) - readdirSync(from).forEach(element => { - const sourcePath = join(from, element) - const destinationPath = join(to, element) - if (lstatSync(sourcePath).isFile()) { - copyFileSync(sourcePath, destinationPath) - } - else { - copyFolderSync(sourcePath, destinationPath) - } - }) - } - - // Copy app dirs - copyFolderSync(appPath, p('app')) - copyFolderSync(publicPath, p('public')) - /* end pkg workaround */ - - // Use this when pkg is no longer used: - // fs.cpSync(appPath, p('app'), { recursive: true }) - // fs.cpSync(publicPath, p('public'), { recursive: true }) + cpSync(appPath, p('app'), { recursive: true }) + cpSync(publicPath, p('public'), { recursive: true }) // Write .gitignore let gitIgnoreTemplate = join(nodeModules, '@enhance', 'starter-project', 'template.gitignore') diff --git a/src/commands/new/errors.js b/src/commands/new/errors.js index d989b61..4bfe927 100644 --- a/src/commands/new/errors.js +++ b/src/commands/new/errors.js @@ -8,7 +8,7 @@ module.exports = function error (params, utils) { project_found: 'Existing Begin app already found in this directory', invalid_appname: `Invalid app name`, invalid_runtime: `Function runtime must be one of: ${backtickify(runtimes)}`, - } + }, } return Error(errors[lang][err]) } diff --git a/src/commands/new/index.js b/src/commands/new/index.js index 453c289..b3e5b9d 100644 --- a/src/commands/new/index.js +++ b/src/commands/new/index.js @@ -32,8 +32,8 @@ module.exports = { name: 'Create a new project with the name my-app', example: 'begin new project -n my-app', }, - ] + ], }, } - } + }, } diff --git a/src/commands/regions/index.js b/src/commands/regions/index.js index 26d7504..6771e2f 100644 --- a/src/commands/regions/index.js +++ b/src/commands/regions/index.js @@ -19,7 +19,7 @@ async function action (params) { const config = getConfig(params) return action({ config, - ...params + ...params, }) } else { diff --git a/src/commands/tail/errors.js b/src/commands/tail/errors.js index 7b5fab4..fcb8b03 100644 --- a/src/commands/tail/errors.js +++ b/src/commands/tail/errors.js @@ -6,7 +6,7 @@ module.exports = function error (params) { app_not_found: 'No app found with that app ID', no_env: 'Environment ID not found, please run with -e or --envID', invalid_env: 'Invalid or incorrect environment ID', - } + }, } return Error(errors[lang][err]) } diff --git a/src/commands/tail/help.js b/src/commands/tail/help.js index 5fa906d..12156c9 100644 --- a/src/commands/tail/help.js +++ b/src/commands/tail/help.js @@ -39,6 +39,6 @@ module.exports = { name: 'Tail logs with grep', example: 'begin tail | grep "GOT HERE"', }, - ] - } + ], + }, } diff --git a/src/commands/team/help.js b/src/commands/team/help.js index 2d1336b..e64d511 100644 --- a/src/commands/team/help.js +++ b/src/commands/team/help.js @@ -56,6 +56,6 @@ module.exports = { name: `Remove a teammate from an app`, example: 'begin team remove $username', }, - ] - } + ], + }, } diff --git a/src/commands/team/index.js b/src/commands/team/index.js index a37345f..340482c 100644 --- a/src/commands/team/index.js +++ b/src/commands/team/index.js @@ -47,7 +47,7 @@ async function action (params) { app, appID, config, - ...params + ...params, }, utils) } else { diff --git a/src/commands/team/invite/index.js b/src/commands/team/invite/index.js index 77fb0af..c61f8eb 100644 --- a/src/commands/team/invite/index.js +++ b/src/commands/team/invite/index.js @@ -17,7 +17,7 @@ module.exports = async function action (params) { return { string: message, - json: invite + json: invite, } } catch (err) { diff --git a/src/commands/telemetry/index.js b/src/commands/telemetry/index.js index bb4b6ed..3a02d0f 100644 --- a/src/commands/telemetry/index.js +++ b/src/commands/telemetry/index.js @@ -1,7 +1,7 @@ module.exports = { names: { en: [ 'telemetry' ] }, action: (params) => { - let { appVersion, args, cliDir, } = params + let { appVersion, args, cliDir } = params let { disable, enable, staging } = args let lib = require('../../lib') @@ -51,7 +51,7 @@ module.exports = { } return { string: message, - json: { message } + json: { message }, } }, help: { @@ -86,7 +86,7 @@ module.exports = { name: 'Disable CLI telemetry', example: 'begin telemetry --disable', }, - ] - } - } + ], + }, + }, } diff --git a/src/commands/tokens/create/index.js b/src/commands/tokens/create/index.js index 2d57938..40aa7e7 100644 --- a/src/commands/tokens/create/index.js +++ b/src/commands/tokens/create/index.js @@ -1,4 +1,4 @@ -module.exports = async function action (params, /* utils */) { +module.exports = async function action (params /* utils */) { let { args, config } = params let { access_token: token, stagingAPI: _staging } = config let c = require('@colors/colors/safe') @@ -14,6 +14,6 @@ module.exports = async function action (params, /* utils */) { `Treat this token as a secret; ${c.bold('do not share or publish it publicly')}` return { string, - json: { tokenID, expires } + json: { tokenID, expires }, } } diff --git a/src/commands/tokens/help.js b/src/commands/tokens/help.js index 36a9901..687de47 100644 --- a/src/commands/tokens/help.js +++ b/src/commands/tokens/help.js @@ -32,6 +32,6 @@ module.exports = { name: `Revoke a token`, example: 'begin tokens revoke $token', }, - ] - } + ], + }, } diff --git a/src/commands/tokens/index.js b/src/commands/tokens/index.js index 21a8f48..096fb62 100644 --- a/src/commands/tokens/index.js +++ b/src/commands/tokens/index.js @@ -1,5 +1,5 @@ let names = { en: [ 'tokens', 'token' ] } -let subcommands = [ 'list', 'create', 'revoke', ] +let subcommands = [ 'list', 'create', 'revoke' ] let aliases = { ls: 'list', } @@ -27,7 +27,7 @@ async function action (params) { let utils = { ...lib } return appAction({ config, - ...params + ...params, }, utils) } else { diff --git a/src/commands/tokens/revoke/index.js b/src/commands/tokens/revoke/index.js index d2f6c9d..a5a514b 100644 --- a/src/commands/tokens/revoke/index.js +++ b/src/commands/tokens/revoke/index.js @@ -8,7 +8,7 @@ module.exports = async function action (params) { await client.tokens.revoke({ token, appID, tokenID, _staging }) return { string: `Revoked token ${tokenID}`, - json: { tokenID } + json: { tokenID }, } } catch (err) { diff --git a/src/commands/update/help.js b/src/commands/update/help.js index 86e5548..d414cc2 100644 --- a/src/commands/update/help.js +++ b/src/commands/update/help.js @@ -1,16 +1,6 @@ module.exports = { en: { - usage: [ 'update', '[options]' ], - description: 'Update Begin to the latest version', - contents: { - header: 'Update options', - items: [ - { - name: '--use', - description: 'Switch between `latest` (stable) and `main` (canary) channels', - optional: true, - }, - ], - } - } + usage: [ 'update' ], + description: '(deprecated) Update Begin to the latest version', + }, } diff --git a/src/commands/update/index.js b/src/commands/update/index.js index a17efd5..0224098 100644 --- a/src/commands/update/index.js +++ b/src/commands/update/index.js @@ -1,138 +1,8 @@ let names = { en: [ 'update', 'upgrade' ] } let help = require('./help') -async function action (params) { - let { appVersion, args, cliDir } = params - let { use } = args - - let { arch, platform: plat } = process - let platform = plat === 'darwin' && 'darwin' || - plat === 'linux' && 'linux' || - plat === 'win32' && 'win32' - let isMac = platform === 'darwin' - let isWin = plat.startsWith('win') - // macOS is the only platform with arm64 releases (for now) - let architecture = isMac && arch === 'arm64' ? 'arm64' : 'x64' - - let _http = require('http') - let _https = require('https') - let { join } = require('path') - let { chmodSync, existsSync, mkdirSync, renameSync, rmSync, writeFileSync } = require('fs') - let semver = require('semver') - let zip = require('adm-zip') - - let versions = await getVersions() - return new Promise((resolve, reject) => { - let appChannel = appVersion.startsWith('main') ? 'main' : 'latest' - - // Allow CLI override when specifying channel - let override = use && use !== appChannel ? use : false - let channel = override || appChannel - - let release = versions.cli[channel] - let version = release.version - let url = release.releases[platform][architecture] - let https = url.startsWith('https://') ? _https : _http - - // Compare versions if we're doing a plain update - let doNotUpdate - if (!override && channel === 'main') doNotUpdate = appVersion === version - if (!override && channel === 'latest') doNotUpdate = semver.gte(appVersion, version) - if (doNotUpdate) { - return resolve('Begin already running the latest version, nice!') - } - - https.get(url, res => { - let mib = i => Math.round((i / 1000 / 1000) * 100) / 100 - let downloadSize = res.headers['content-length'] || res.headers['Content-Length'] - let target = mib(downloadSize) - console.error('Downloading', url, `(${target} MiB)`) - - let body = [] - let size = 0 - let chunks = 0 - let percent = () => Math.round((size / downloadSize) * 100) - res.on('data', data => { - body.push(data) - size += data.length - chunks++ - if (chunks % 100 === 0) { - process.stderr.write(`Got ${mib(size)} MiB of ${target} MiB (${percent()}%)`) - process.stderr.cursorTo(0) - } - }) - res.on('end', data => { - if (data) body.push(data) - body = Buffer.concat(body) - process.stderr.write(`Got ${mib(body.length)} MiB of ${target} MiB (${percent()}%)\n`) - - mkdirSync(cliDir, { recursive: true }) - let exe = 0o755 // -rwxr-xr-x - let Zip = new zip(body) - for (let file of Zip.getEntries()) { - let decompressed = Zip.readFile(file) - let filename = join(cliDir, file.entryName) - - // Recent versions of macOS implement runtime code signing enforcement - // The kernel links and caches code signatures of individual files upon first use; simply overwriting an executable with a new file will result in a `Killed: 9` error - // Instead, we must politely move the old binary out of the way, destroy it, and write a new file - // See also: https://developer.apple.com/videos/play/wwdc2019/703 @14:00 - if (isMac && existsSync(filename)) { - let old = filename + '-old' - renameSync(filename, old) - rmSync(old, { force: true }) - } - - writeFileSync(filename, decompressed) - if (!isWin) { - chmodSync(filename, exe) - } - console.error(`Upgrading Begin to ${version}`) - console.error(`Updated ${filename}`) - resolve('Successfully upgraded Begin!') - } - }) - res.on('err', err => { - err.message = `Upgrade failed, please try again` - reject(err) - }) - }) - }) -} - -async function getVersions () { - let _http = require('http') - let _https = require('https') - let { __BEGIN_TEST_URL__ } = process.env - return new Promise((resolve, reject) => { - let url = __BEGIN_TEST_URL__ - ? __BEGIN_TEST_URL__ - : 'https://dl.begin.com/versions' - let https = url.startsWith('https://') ? _https : _http - console.error('Checking for latest version') - let failed = 'Failed to check latest version' - https.get(url, res => { - let body = [] - res.on('data', data => { - body.push(data) - }) - res.on('end', data => { - if (data) body.push(data) - try { - let versions = JSON.parse(Buffer.concat(body)) - resolve(versions) - } - catch (err) { - err.message = failed - reject(err) - } - }) - res.on('err', err => { - err.message = failed - reject(err) - }) - }) - }) +async function action () { + return 'Use npm to update the Begin CLI to the latest version.' } module.exports = { diff --git a/src/commands/version/index.js b/src/commands/version/index.js index 3b180e1..5983e4e 100644 --- a/src/commands/version/index.js +++ b/src/commands/version/index.js @@ -8,7 +8,7 @@ module.exports = { begin: process.argv[0], version: appVersion, message, - } + }, } - } + }, } diff --git a/src/index.js b/src/index.js index d6532ee..d277971 100755 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ let { existsSync, readFileSync } = require('fs') let { join } = require('path') let { homedir } = require('os') let minimist = require('minimist') +let update = require('update-notifier-cjs') let commands = require('./commands') let _printer = require('./printer') let telemetry = require('./lib/telemetry') @@ -34,10 +35,6 @@ async function begin (params = {}) { let cliDir = process.env.BEGIN_INSTALL || join(homedir(), '.begin') let isCI = args.input === false || (process.env.CI || !process.stdout.isTTY) || false let params = { args, appVersion: version, cliDir, clientIDs, isCI, lang, printer } - - printer('\x1b[41m\x1b[37m\x1b[1m DEPRECATION NOTICE: \x1b[0m \x1b[31m\x1b[1mThe Begin Deploy CLI is now updated via npm\x1b[0m') - printer('\x1b[1mPlease run "npm install -g @begin/deploy" to install the latest version\x1b[0m\n') - await commands(params) telemetry.end(params) } @@ -48,6 +45,10 @@ async function begin (params = {}) { // Invoke to start if not running in module (test) mode if (require.main === module) { + let pkg = require('../package.json') + let boxenOpts = { padding: 1, margin: 1, align: 'center', borderColor: 'green', borderStyle: 'round', dimBorder: true } + update({ pkg, shouldNotifyInNpmScript: true }).notify({ boxenOpts }) + begin() } diff --git a/src/lib/app/create-app.js b/src/lib/app/create-app.js index fffc945..c0ae444 100644 --- a/src/lib/app/create-app.js +++ b/src/lib/app/create-app.js @@ -30,7 +30,7 @@ module.exports = async function createApp (params, utils) { validate: (value) => { if (!value) return 'A name is required to create a new app' return true - } + }, }, promptOptions) if (env) { @@ -43,7 +43,7 @@ module.exports = async function createApp (params, utils) { name: 'envName', message: 'What would you like to name your first environment?', initial: 'staging', - validate: validateEnvName.prompt + validate: validateEnvName.prompt, }, promptOptions) } @@ -103,7 +103,7 @@ module.exports = async function createApp (params, utils) { let updatedArc = mutateArc.upsert({ item: `appID ${appID}`, pragma: 'begin', - raw: inventory.inv._project.raw + raw: inventory.inv._project.raw, }) writeFile(inventory.inv._project.manifest, updatedArc) console.error(`Added appID '${appID}' to project, be sure to commit this change!`) diff --git a/src/lib/app/validate.js b/src/lib/app/validate.js index f0a1406..b74578f 100644 --- a/src/lib/app/validate.js +++ b/src/lib/app/validate.js @@ -17,7 +17,7 @@ let validateEnvName = { if (name === 'testing') return cannotBeTesting if (!name) return envRequired return looseName.test(name) - } + }, } module.exports = { diff --git a/src/lib/index.js b/src/lib/index.js index 3ec84f7..b9b0dce 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -24,7 +24,7 @@ function getAppID (inventory, args) { appID = begin?.find(i => i[0] === 'appID' && typeof i[1] === 'string')?.[1] } // Account for possible unintended minimist arg errata - appID = appID !== true && appID || undefined + appID = (appID !== true && appID) || undefined if (!appID) { throw Error(`Please specify an appID or run this command from within your app's folder`) } @@ -100,7 +100,7 @@ function writeFile (params) { en: { created_file: str => `Created file: ${str}`, updated_file: str => `Updated file: ${str}`, - } + }, } return function (path, contents) { diff --git a/src/lib/mutate-arc.js b/src/lib/mutate-arc.js index b58fcb7..079607f 100644 --- a/src/lib/mutate-arc.js +++ b/src/lib/mutate-arc.js @@ -91,5 +91,5 @@ function upsert (params) { } module.exports = { - upsert + upsert, } diff --git a/src/lib/npm-commands.js b/src/lib/npm-commands.js index 904ea40..0ea23d8 100644 --- a/src/lib/npm-commands.js +++ b/src/lib/npm-commands.js @@ -64,5 +64,5 @@ async function initialInstall (params, cwd) { module.exports = { installAwsSdk, installDependencies, - initialInstall + initialInstall, } diff --git a/src/pkg-index.js b/src/pkg-index.js index 985fda8..2845af5 100755 --- a/src/pkg-index.js +++ b/src/pkg-index.js @@ -1,5 +1,8 @@ #! /usr/bin/env node -process.env.BEGIN_CLI_TYPE = 'BINARY' +if (process.stdin.isTTY) { + process.stderr.write('\n\x1b[41m\x1b[37m\x1b[1m DEPRECATION NOTICE: \x1b[0m \x1b[31m\x1b[1mThe Begin Deploy CLI is now updated via npm\x1b[0m\n') + process.stderr.write('\x1b[1mPlease run "npm install -g @begin/deploy" to install the latest version\x1b[0m\n\n') +} require('./index')() diff --git a/src/printer/error-check.js b/src/printer/error-check.js deleted file mode 100644 index 2e24927..0000000 --- a/src/printer/error-check.js +++ /dev/null @@ -1,14 +0,0 @@ -// Handle special pkg-specific error states -module.exports = function errorCheck (err) { - if (!process.pkg) return err - - // ESM plugins were used, which pkg does not yet support (vercel/pkg#1291) - let invalidHost = 'Invalid host defined options' - if (err.message.includes(invalidHost)) { - let txt = 'ESM plugins not yet supported in Begin; for more information please see https://github.com/vercel/pkg/issues/1291' - let msg = err.message.replace(invalidHost, txt) - return Error(msg) - } - - return err -} diff --git a/src/printer/index.js b/src/printer/index.js index 48fd1ab..bd7607f 100644 --- a/src/printer/index.js +++ b/src/printer/index.js @@ -8,8 +8,6 @@ function printer (args) { let isError = out instanceof Error if (isError) { process.exitCode = 1 - let errorCheck = require('./error-check') - out = errorCheck(out) } let errored = process.exitCode === 1 diff --git a/test/integration/commands/builds-disabled.js b/test/integration/commands/builds-disabled.js index 6d23561..65c4a6f 100644 --- a/test/integration/commands/builds-disabled.js +++ b/test/integration/commands/builds-disabled.js @@ -1,7 +1,6 @@ +let { join } = require('node:path') let test = require('tape') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, run, getInv, newFolder } = require(lib) +let { begin: _begin, getInv, newTmpFolder } = require('../../lib') let { writeFileSync } = require('fs') function appendAppID (i) { @@ -9,13 +8,8 @@ function appendAppID (i) { } test('Run builds tests', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Help / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Help]` + let begin = _begin.bind({}, t) let newAppDir = 'new-app' @@ -31,7 +25,7 @@ async function runTests (runType, t) { t.match(r.stderr, noAppFound, 'No app ID') // Create project and check builds - cwd = newFolder(newAppDir) + cwd = newTmpFolder(newAppDir) r = await begin('new project -p .', cwd) i = await getInv(t, cwd) t.pass('Project is valid') @@ -56,7 +50,7 @@ async function runTests (runType, t) { t.equal(r.code, 1, 'Exited 1') // Create project and check builds - cwd = newFolder(newAppDir) + cwd = newTmpFolder(newAppDir) r = await begin('new project -p . --json', cwd) i = await getInv(t, cwd) t.pass('Project is valid') @@ -71,4 +65,5 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) diff --git a/test/integration/commands/dev-test.js b/test/integration/commands/dev-test.js index 61c7bba..48c4f96 100644 --- a/test/integration/commands/dev-test.js +++ b/test/integration/commands/dev-test.js @@ -1,9 +1,8 @@ +let { writeFileSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { writeFileSync } = require('fs') -let { join } = require('path') let tiny = require('tiny-json-http') -let lib = join(process.cwd(), 'test', 'lib') -let { newTmpFolder, run, start, shutdown } = require(lib) +let { newTmpFolder, start, shutdown } = require('../../lib') let arc = `@app hi @@ -16,12 +15,7 @@ hi let url test('Run dev tests', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Dev / ${runType}]` + let mode = '[Dev]' let newDevDir = 'dev' @@ -34,7 +28,7 @@ async function runTests (runType, t) { let handler = `exports.handler = async req => req` writeFileSync(handlerFile, handler) - let port = await start[runType](t, cwd) + let port = await start(t, cwd) url = `http://localhost:${port}` }) @@ -57,4 +51,7 @@ async function runTests (runType, t) { t.test(`${mode} Shut down Sandbox`, t => { shutdown(t) }) -} + + t.end() +}) + diff --git a/test/integration/commands/generate/api-test.js b/test/integration/commands/generate/api-test.js index e7ae449..31cfbc4 100644 --- a/test/integration/commands/generate/api-test.js +++ b/test/integration/commands/generate/api-test.js @@ -1,17 +1,11 @@ +let { existsSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder, run } = require(lib) +let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder } = require('../../../lib') test('Run generate tests (API)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Generate / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Generat]` + let begin = _begin.bind({}, t) let pathNotFound = /API path not found/ let pathInvalid = /Invalid API path/ @@ -120,4 +114,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/generate/element-test.js b/test/integration/commands/generate/element-test.js index f558fba..9f87e23 100644 --- a/test/integration/commands/generate/element-test.js +++ b/test/integration/commands/generate/element-test.js @@ -1,17 +1,11 @@ +let { existsSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder, run } = require(lib) +let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder } = require('../../../lib') test('Run generate tests (element)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Generate / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Generate]` + let begin = _begin.bind({}, t) let nameNotFound = /Element name not found/ let nameInvalid = /The supplied element name is invalid/ @@ -146,4 +140,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/generate/event-test.js b/test/integration/commands/generate/event-test.js index 53e4e9c..355bb30 100644 --- a/test/integration/commands/generate/event-test.js +++ b/test/integration/commands/generate/event-test.js @@ -1,17 +1,11 @@ +let { existsSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder, run } = require(lib) +let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder } = require('../../../lib') test('Run generate tests (event)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Generate / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Generate]` + let begin = _begin.bind({}, t) let nameNotFound = /Event name not found/ let nameInvalid = /Invalid event name/ @@ -142,4 +136,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/generate/help-test.js b/test/integration/commands/generate/help-test.js index 447a5db..61e1df0 100644 --- a/test/integration/commands/generate/help-test.js +++ b/test/integration/commands/generate/help-test.js @@ -1,16 +1,9 @@ let test = require('tape') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, run } = require(lib) +let { begin: _begin } = require('../../../lib') test('Run generate tests (help)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Generate / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Generate]` + let begin = _begin.bind({}, t) let globalOptions = /Global options\:/ let noType = /Please specify a generator to run/ @@ -89,4 +82,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/generate/http-test.js b/test/integration/commands/generate/http-test.js index c8df58c..a072413 100644 --- a/test/integration/commands/generate/http-test.js +++ b/test/integration/commands/generate/http-test.js @@ -1,17 +1,11 @@ +let { existsSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder, run } = require(lib) +let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder } = require('../../../lib') test('Run generate tests (http)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Generate / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Generate]` + let begin = _begin.bind({}, t) let methodInvalid = /Invalid HTTP method/ let pathNotFound = /HTTP path not found/ @@ -230,4 +224,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/generate/page-test.js b/test/integration/commands/generate/page-test.js index 422eb7c..c216bb6 100644 --- a/test/integration/commands/generate/page-test.js +++ b/test/integration/commands/generate/page-test.js @@ -1,17 +1,11 @@ +let { existsSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder, run } = require(lib) +let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder } = require('../../../lib') test('Run generate tests (page)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Generate / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Generate]` + let begin = _begin.bind({}, t) let pathNotFound = /Page path not found/ let pathInvalid = /Invalid page path/ @@ -152,4 +146,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/generate/scaffold-test.js b/test/integration/commands/generate/scaffold-test.js index 10e1fb5..1eeaa7f 100644 --- a/test/integration/commands/generate/scaffold-test.js +++ b/test/integration/commands/generate/scaffold-test.js @@ -1,17 +1,11 @@ +let { existsSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder, run } = require(lib) +let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder } = require('../../../lib') test('Run generate tests (scaffold)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Generate / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Generate]` + let begin = _begin.bind({}, t) let newAppDir = 'crud-app' let alreadyExists = /The schema already exists/ @@ -192,4 +186,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/generate/scheduled-test.js b/test/integration/commands/generate/scheduled-test.js index a597605..ac195aa 100644 --- a/test/integration/commands/generate/scheduled-test.js +++ b/test/integration/commands/generate/scheduled-test.js @@ -1,17 +1,11 @@ +let { existsSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder, run } = require(lib) +let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder } = require('../../../lib') test('Run generate tests (scheduled)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Generate / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Generate]` + let begin = _begin.bind({}, t) let nameNotFound = /Scheduled name not found/ let nameInvalid = /Invalid scheduled name/ @@ -215,4 +209,5 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) diff --git a/test/integration/commands/help-test.js b/test/integration/commands/help-test.js index ed44770..f169d72 100644 --- a/test/integration/commands/help-test.js +++ b/test/integration/commands/help-test.js @@ -1,16 +1,9 @@ let test = require('tape') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, run } = require(lib) +let { begin: _begin } = require('../../lib') test('Run help tests', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Help / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = '[Help]' + let begin = _begin.bind({}, t) let errCmd = /ohnoes/ let globalOptions = /Global options\:/ @@ -130,4 +123,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/login-test.js b/test/integration/commands/login-test.js index d91c124..816b901 100644 --- a/test/integration/commands/login-test.js +++ b/test/integration/commands/login-test.js @@ -1,21 +1,17 @@ +let { existsSync } = require('node:fs') +let { readFile } = require('node:fs/promises') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { readFile } = require('fs/promises') -let { join } = require('path') +let { begin: _begin, newTmpFolder, start, shutdown } = require('../../lib') + let cwd = process.cwd() -let lib = join(cwd, 'test', 'lib') let mock = join(cwd, 'test', 'mock') -let { begin: _begin, newTmpFolder, run, start, shutdown } = require(lib) + let filePath = folder => join(folder, 'config.json') test('Run login tests', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Login / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Login]` + let begin = _begin.bind({}, t) let loginDir = 'login' let loggedIn = 'Successfully logged in!' @@ -23,7 +19,7 @@ async function runTests (runType, t) { let port, pleaseAuth t.test(`${mode} Start dev server`, async t => { - port = await start[runType](t, mock) + port = await start(t, mock) pleaseAuth = `Please authenticate by visiting: http://localhost:${port}/auth?user_code=bar?user_code=bar\nAwaiting authentication...` }) @@ -37,7 +33,7 @@ async function runTests (runType, t) { process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}` r = await begin('login') if (!existsSync(path)) t.fail(`Did not find config.json at ${path}`) - file = JSON.parse(await readFile(path)) + file = JSON.parse((await readFile(path)).toString()) t.ok(file['// Begin config'], 'Got Begin config file comment') t.ok(file.created, 'Got config.created property') t.ok(file.createdVer, 'Got config.createdVer property') @@ -65,7 +61,7 @@ async function runTests (runType, t) { r = await begin('login --json') json = JSON.parse(r.stdout) if (!existsSync(path)) t.fail(`Did not find config.json at ${path}`) - file = JSON.parse(await readFile(path)) + file = JSON.parse((await readFile(path)).toString()) t.ok(file['// Begin config'], 'Got Begin config file comment') t.ok(file.created, 'Got config.created property') t.ok(file.createdVer, 'Got config.createdVer property') @@ -99,4 +95,6 @@ async function runTests (runType, t) { delete process.env.BEGIN_INSTALL delete process.env.__BEGIN_TEST_URL__ }) -} + t.end() +}) + diff --git a/test/integration/commands/logout-test.js b/test/integration/commands/logout-test.js index 43f049e..ba707e1 100644 --- a/test/integration/commands/logout-test.js +++ b/test/integration/commands/logout-test.js @@ -1,21 +1,17 @@ +let { existsSync, mkdirSync, writeFileSync } = require('node:fs') +let { readFile } = require('node:fs/promises') +let { join } = require('node:path') let test = require('tape') -let { existsSync, mkdirSync, writeFileSync } = require('fs') -let { readFile } = require('fs/promises') -let { join } = require('path') +let { begin: _begin, newTmpFolder, start, shutdown } = require('../../lib') + let cwd = process.cwd() -let lib = join(cwd, 'test', 'lib') let mock = join(cwd, 'test', 'mock') -let { begin: _begin, newTmpFolder, run, start, shutdown } = require(lib) + let filePath = folder => join(folder, 'config.json') test('Run logout tests', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Logout / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Logout]` + let begin = _begin.bind({}, t) let logoutDir = 'logout' let loggedOut = 'Successfully logged out!' @@ -28,7 +24,7 @@ async function runTests (runType, t) { }, null, 2) t.test(`${mode} Start dev server`, async t => { - port = await start[runType](t, mock) + port = await start(t, mock) }) t.test(`${mode} Normal`, async t => { @@ -43,7 +39,7 @@ async function runTests (runType, t) { process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}` r = await begin('logout') if (!existsSync(path)) t.fail(`Did not find config.json at ${path}`) - file = JSON.parse(await readFile(path)) + file = JSON.parse((await readFile(path)).toString()) t.notOk(file.access_token, 'config.access_token property no longer found') t.notOk(file.device_code, 'config.device_code property no longer found') t.equal(r.stdout, loggedOut, 'Got logout confirmation') @@ -68,7 +64,7 @@ async function runTests (runType, t) { r = await begin('logout --json') json = JSON.parse(r.stdout) if (!existsSync(path)) t.fail(`Did not find config.json at ${path}`) - file = JSON.parse(await readFile(path)) + file = JSON.parse((await readFile(path)).toString()) t.notOk(file.access_token, 'config.access_token property no longer found') t.notOk(file.device_code, 'config.device_code property no longer found') t.equal(json.ok, true, 'Got ok: true for logout confirmation') @@ -96,4 +92,6 @@ async function runTests (runType, t) { delete process.env.BEGIN_INSTALL delete process.env.__BEGIN_TEST_URL__ }) -} + t.end() +}) + diff --git a/test/integration/commands/new-test-slow.js b/test/integration/commands/new-test-slow.js index 8df9d8e..dafcdbb 100644 --- a/test/integration/commands/new-test-slow.js +++ b/test/integration/commands/new-test-slow.js @@ -1,17 +1,10 @@ let test = require('tape') -let { join } = require('path') let tiny = require('tiny-json-http') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, newTmpFolder, run, start, shutdown } = require(lib) +let { begin: _begin, newTmpFolder, start, shutdown } = require('../../lib') test('Run new tests (slow)', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[New / ${runType} (slow)]` - let begin = _begin[runType].bind({}, t) + let mode = `[New (slow)]` + let begin = _begin.bind({}, t) let newAppDir = 'new' let installing = /Installing dependencies/ @@ -29,7 +22,7 @@ async function runTests (runType, t) { }) t.test(`${mode} Start Begin dev`, async t => { - let port = await start[runType](t, cwd) + let port = await start(t, cwd) url = `http://localhost:${port}` }) @@ -37,7 +30,7 @@ async function runTests (runType, t) { t.plan(1) tiny.get({ url }, function _got (err, result) { if (err) t.fail(err) - else t.ok(result.body.includes('https://enhance.dev'), 'Got valid Enhance starter project response') + else t.ok(result?.body.includes('https://enhance.dev'), 'Got valid Enhance starter project response') }) }) @@ -45,4 +38,6 @@ async function runTests (runType, t) { delete process.env.__SLOW__ shutdown(t) }) -} + t.end() +}) + diff --git a/test/integration/commands/new-test.js b/test/integration/commands/new-test.js index a0818d2..57b5354 100644 --- a/test/integration/commands/new-test.js +++ b/test/integration/commands/new-test.js @@ -1,17 +1,11 @@ +let { existsSync } = require('node:fs') +let { join } = require('node:path') let test = require('tape') -let { existsSync } = require('fs') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder, run } = require(lib) +let { begin: _begin, defaultNumberOfLambdas, getInv, newTmpFolder } = require('../../lib') test('Run new tests', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[New / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = '[New]' + let begin = _begin.bind({}, t) let newAppDir = 'new' let appFound = /Existing Begin app already found in this directory/ @@ -124,4 +118,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 1, 'Exited 1') }) -} + t.end() +}) + diff --git a/test/integration/commands/update-test.js b/test/integration/commands/update-test.js index 69f6035..c34ad36 100644 --- a/test/integration/commands/update-test.js +++ b/test/integration/commands/update-test.js @@ -1,178 +1,17 @@ let test = require('tape') -let { constants: fsConstants, existsSync } = require('fs') -let { access, readFile } = require('fs/promises') -let { join } = require('path') -let cwd = process.cwd() -let lib = join(cwd, 'test', 'lib') -let mock = join(cwd, 'test', 'mock') -let { begin: _begin, newTmpFolder, run, start, shutdown } = require(lib) -let filePath = folder => join(folder, 'hi.txt') +let { begin: _begin } = require('../../lib') -test('Run update tests', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Update / ${runType}]` - let begin = _begin[runType].bind({}, t) - - let upgraded = 'Successfully upgraded Begin!' - let x64Release = /file-x64.zip/ - let arm64Release = /file-arm64.zip/ - let upgradeVer = /10000\.0\.0/ - let didNotUpgrade = 'Begin already running the latest version, nice!' - let contents = 'henlo!\n' - let failed = /Failed to check latest version/ - let port - - t.test(`${mode} Start dev server`, async t => { - port = await start[runType](t, mock) - }) - - if (process.arch === 'x64') { - t.test(`${mode} Normal (x64)`, async t => { - t.plan(9) - let file, folder, path, r - - folder = newTmpFolder(t, 'install') - path = filePath(folder) - process.env.BEGIN_INSTALL = folder - process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}/versions-upgrade` - r = await begin('update') - if (!existsSync(path)) t.fail(`Did not find unzipped / installed file at ${path}`) - file = await readFile(path) - await isExecutable(t, path) - t.equal(file.toString(), contents, 'File unzipped into correct location') - t.equal(r.stdout, upgraded, 'Got upgrade confirmation') - t.match(r.stderr, x64Release, 'Printed x64 release to stderr') - t.match(r.stderr, upgradeVer, 'Printed upgrade version to stderr') - t.ok(r.stderr.includes(path), 'Printed destination filepath to stderr') - t.equal(r.code, 0, 'Exited 0') - - folder = newTmpFolder(t, 'install') - path = filePath(folder) - process.env.BEGIN_INSTALL = folder - process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}/versions-ok` - r = await begin('update') - if (existsSync(path)) t.fail(`Found unzipped / installed file at ${path}`) - t.equal(r.stdout, didNotUpgrade, `Got confirmation that upgrade wasn't necessary`) - t.ok(r.stderr, 'Printed update info stderr') - t.equal(r.code, 0, 'Exited 0') - }) - } - // arm64-enabled tests (which effectively means macOS only for now) - else if (process.arch === 'arm64') { - t.test(`${mode} Normal (arm64)`, async t => { - t.plan(9) - let file, folder, path, r - - folder = newTmpFolder(t, 'install') - path = filePath(folder) - process.env.BEGIN_INSTALL = folder - process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}/versions-upgrade` - r = await begin('update') - if (!existsSync(path)) t.fail(`Did not find unzipped / installed file at ${path}`) - file = await readFile(path) - await isExecutable(t, path) - t.equal(file.toString(), contents, 'File unzipped into correct location') - t.equal(r.stdout, upgraded, 'Got upgrade confirmation') - t.match(r.stderr, arm64Release, 'Printed arm64 release to stderr') - t.match(r.stderr, upgradeVer, 'Printed upgrade version to stderr') - t.ok(r.stderr.includes(path), 'Printed destination filepath to stderr') - t.equal(r.code, 0, 'Exited 0') - - folder = newTmpFolder(t, 'install') - path = filePath(folder) - process.env.BEGIN_INSTALL = folder - process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}/versions-ok` - r = await begin('update') - if (existsSync(path)) t.fail(`Found unzipped / installed file at ${path}`) - t.equal(r.stdout, didNotUpgrade, `Got confirmation that upgrade wasn't necessary`) - t.ok(r.stderr, 'Printed update info stderr') - t.equal(r.code, 0, 'Exited 0') - }) - } - - t.test(`${mode} Errors`, async t => { - t.plan(3) - let folder, path, r - folder = newTmpFolder(t, 'install') - path = filePath(folder) - process.env.BEGIN_INSTALL = folder - process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}/lolidk` - r = await begin('update') - if (existsSync(path)) t.fail(`Found unzipped / installed file at ${path}`) - t.notOk(r.stdout, 'Did not print to stdout') - t.ok(r.stderr, 'Printed error to stderr') - t.equal(r.code, 1, 'Exited 1') - }) - - t.test(`${mode} JSON`, async t => { - t.plan(10) - let file, folder, json, path, r +test('Run update tests', async t => { + let mode = `[Update]` + let begin = _begin.bind({}, t) - folder = newTmpFolder(t, 'install') - path = filePath(folder) - process.env.BEGIN_INSTALL = folder - process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}/versions-upgrade` - r = await begin('update --json') - if (!existsSync(path)) t.fail(`Did not find unzipped / installed file at ${path}`) - file = await readFile(path) - json = JSON.parse(r.stdout) - await isExecutable(t, path) - t.equal(file.toString(), contents, 'File unzipped into correct location') - t.equal(json.ok, true, 'Got ok: true for upgrade confirmation') - t.ok(json.message, 'Got message for upgrade confirmation') - t.match(r.stderr, upgradeVer, 'Printed upgrade version to stderr') - t.ok(r.stderr.includes(path), 'Printed destination filepath to stderr') - t.equal(r.code, 0, 'Exited 0') + let notice = 'Use npm to update the Begin CLI' - folder = newTmpFolder(t, 'install') - path = filePath(folder) - process.env.BEGIN_INSTALL = folder - process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}/versions-ok` - r = await begin('update --json') - if (existsSync(path)) t.fail(`Found unzipped / installed file at ${path}`) - json = JSON.parse(r.stdout) - t.equal(json.ok, true, 'Got ok: true for upgrade confirmation') - t.ok(json.message, 'Got message for upgrade confirmation') - t.ok(r.stderr, 'Printed update info stderr') + t.test(`${mode} "use npm"`, async t => { + t.plan(2) + const r = await begin('update') + t.ok(r.stdout.includes(notice), 'Got upgrade confirmation') t.equal(r.code, 0, 'Exited 0') - - // TODO test --use flag - }) - - t.test(`${mode} Errors (JSON)`, async t => { - t.plan(4) - let json, r - - process.env.__BEGIN_TEST_URL__ = `http://localhost:${port}/lolidk` - r = await begin('update --json') - json = JSON.parse(r.stdout) - t.equal(json.ok, false, 'Got ok: false') - t.match(json.error, failed, 'Errored on upgrade') - t.ok(r.stderr, 'Printed update info stderr') - t.equal(r.code, 1, 'Exited 1') - }) - - t.test(`${mode} Shut down dev server`, t => { - shutdown(t) - process.exitCode = 0 - delete process.env.BEGIN_INSTALL - delete process.env.__BEGIN_TEST_URL__ }) -} - -// Confirm the file written to the filesystem is chmod +x -async function isExecutable (t, filePath) { - if (!process.platform.startsWith('win')) { - try { - await access(filePath, fsConstants.X_OK) - } - catch (err) { - t.fail(`File is not executable: ${filePath}`) - } - } -} +}) diff --git a/test/integration/commands/version-test.js b/test/integration/commands/version-test.js index d930e0d..632963c 100644 --- a/test/integration/commands/version-test.js +++ b/test/integration/commands/version-test.js @@ -1,16 +1,9 @@ let test = require('tape') -let { join } = require('path') -let lib = join(process.cwd(), 'test', 'lib') -let { begin: _begin, run } = require(lib) +let { begin: _begin } = require('../../lib') test('Run version tests', async t => { - await run(runTests, t) - t.end() -}) - -async function runTests (runType, t) { - let mode = `[Version / ${runType}]` - let begin = _begin[runType].bind({}, t) + let mode = `[Version]` + let begin = _begin.bind({}, t) let fullVer = /^Begin \d+\.\d+\.\d+$/ let ver = /^\d+\.\d+\.\d+$/ @@ -62,4 +55,6 @@ async function runTests (runType, t) { t.notOk(r.stderr, 'Did not print to stderr') t.equal(r.code, 0, 'Exited 0') }) -} + t.end() +}) + diff --git a/test/lib/_begin.js b/test/lib/_begin.js index fa1a1e2..88a15ee 100644 --- a/test/lib/_begin.js +++ b/test/lib/_begin.js @@ -1,17 +1,10 @@ -let { join } = require('path') -let { exec: _exec } = require('child_process') -let { promisify } = require('util') let { parseArgsStringToArgv: getArgs } = require('string-argv') -let exec = promisify(_exec) let capture = require('./_capture') let tmp = require('./_tmp-dir') let cwd = process.cwd() -let isWin = process.platform.startsWith('win') let mod = require(cwd) -let binPath = join(cwd, 'build', `begin${isWin ? '.exe' : ''}`) -let bin = join(binPath) let argv = process.argv let json = i => JSON.stringify(i) @@ -27,42 +20,19 @@ function reset (t) { capture.reset() } -module.exports = { - module: async (t, args, dir) => { - process.chdir(dir || tmp) - process.argv = [ 'fake-env', 'fake-file', ...getArgs(args), disableTelemetry ] - process.exitCode = 0 - capture.start() - await mod() - capture.stop() - let { stdout, stderr } = capture - reset(t) - return { - type: 'module', - stdout: stdout.trim(), - stderr: stderr.trim(), - code: process.exitCode - } - }, - binary: async (t, args, dir) => { - let opts = { cwd: dir || tmp, shell: true } - let cmd = `${bin} ${args} ${disableTelemetry}` - let result, code - try { - process.exitCode = 0 - result = await exec(cmd, opts) - code = result.error?.code - } - catch (error) { - result = error - code = error?.code - } - reset(t) - return { - type: 'binary', - stdout: result.stdout?.toString()?.trim(), - stderr: result.stderr?.toString()?.trim(), - code: code || 0, - } - }, +module.exports = async (t, args, dir) => { + process.chdir(dir || tmp) + process.argv = [ 'fake-env', 'fake-file', ...getArgs(args), disableTelemetry ] + process.exitCode = 0 + capture.start() + await mod() + capture.stop() + let { stdout, stderr } = capture + reset(t) + return { + type: 'module', + stdout: stdout.trim(), + stderr: stderr.trim(), + code: process.exitCode, + } } diff --git a/test/lib/_capture.js b/test/lib/_capture.js index 1ceca0e..089513a 100644 --- a/test/lib/_capture.js +++ b/test/lib/_capture.js @@ -1,5 +1,5 @@ let log = console.log -let err = console.err +let err = console.error let capture = { start: () => { @@ -9,7 +9,7 @@ let capture = { }, stop: () => { console.log = log - console.err = err + console.error = err }, stdout: '', stderr: '', diff --git a/test/lib/_get-args.js b/test/lib/_get-args.js deleted file mode 100644 index 29899ac..0000000 --- a/test/lib/_get-args.js +++ /dev/null @@ -1 +0,0 @@ -console.log(JSON.stringify(process.argv)) diff --git a/test/lib/_start-shutdown.js b/test/lib/_start-shutdown.js index 06321e9..a92ad44 100644 --- a/test/lib/_start-shutdown.js +++ b/test/lib/_start-shutdown.js @@ -1,19 +1,15 @@ -let { spawn } = require('child_process') -let { join } = require('path') -let net = require('net') +let { spawn } = require('node:child_process') +let net = require('node:net') let tiny = require('tiny-json-http') let child let url let cwd = process.cwd() -let isWin = process.platform.startsWith('win') -let binPath = join(cwd, 'build', `begin${isWin ? '.exe' : ''}`) -let bin = join(binPath) let ready = /.* dev server \(.*\) ready!/ -async function startDev (type, t, dir, reuse, options = {}) { +async function startDev (t, dir, reuse, options = {}) { let port = await getPort() // TODO: fix Sandbox (and this) to accept a ports property at some point? let _arc = port + 100 // Yeah, this magic number can definitely break, but it's pretty unlikely in a CI context @@ -26,8 +22,8 @@ async function startDev (type, t, dir, reuse, options = {}) { let { confirmStarted, print } = options if (child) throw Error('Unclean test env, found hanging child process!') // Quiet overrides are a bit more abstracted here bc we have to print from a child - let cmd = type === 'module' ? 'node' : bin - let args = type === 'module' ? [ cwd ] : [] + let cmd = 'node' + let args = [ cwd ] args.push('dev', '--port', `${port}`, '--disable-telemetry') child = spawn(cmd, args, { cwd: dir, @@ -39,7 +35,7 @@ async function startDev (type, t, dir, reuse, options = {}) { if (print && started) { console.log(chunk.toString()) } if ((data.match(ready) || data.includes(confirmStarted)) && !started) { started = true - t.pass(`Begin dev server started (${type}, http: ${port}, _arc: ${port})`) + t.pass(`Begin dev server started (http: ${port}, _arc: ${port})`) resolve(port) } } @@ -92,15 +88,6 @@ async function verifyShutdown (t) { } } -module.exports = { - start: { - module: startDev.bind({}, 'module'), - binary: startDev.bind({}, 'binary'), - }, - shutdown, - getPort, -} - /** * Ensure we have access to the desired HTTP port! * Ported (ahem) from @architect/sandbox @@ -145,3 +132,9 @@ function getPort () { check() }) } + +module.exports = { + start: startDev, + shutdown, + getPort, +} diff --git a/test/lib/index.js b/test/lib/index.js index b772e35..0adf22f 100644 --- a/test/lib/index.js +++ b/test/lib/index.js @@ -1,5 +1,3 @@ -let { existsSync } = require('fs') -let { join } = require('path') let inventory = require('@architect/inventory') let begin = require('./_begin') @@ -8,17 +6,6 @@ let newTmpFolder = require('./_new-tmp-folder') let { start, shutdown, getPort } = require('./_start-shutdown') let tmp = require('./_tmp-dir') -// Integration test runner -let bin = join(process.cwd(), 'build', `begin${process.platform.startsWith('win') ? '.exe' : ''}`) -let run = async (runTests, t) => { - if (!process.env.BINARY_ONLY) { - await runTests('module', t) - } - if (!process.env.MODULE_ONLY && existsSync(bin)) { - await runTests('binary', t) - } -} - let defaultNumberOfLambdas = 5 async function getInv (t, cwd) { @@ -37,7 +24,6 @@ module.exports = { getInv, getPort, newTmpFolder, - run, shutdown, start, tmp, diff --git a/test/mock/releases.js b/test/mock/releases.js index dbcdffa..afa0304 100644 --- a/test/mock/releases.js +++ b/test/mock/releases.js @@ -18,6 +18,6 @@ module.exports = function (version) { releases, version, }, - } + }, } } diff --git a/test/unit/commands/index-test.js b/test/unit/commands/index-test.js index 0d314ca..d118c99 100644 --- a/test/unit/commands/index-test.js +++ b/test/unit/commands/index-test.js @@ -1,8 +1,7 @@ let test = require('tape') -let { join } = require('path') let minimist = require('minimist') -let sut = join(process.cwd(), 'src', 'commands') -let commands = require(sut) + +let commands = require('../../../src/commands') let lang = 'en' let printed = [] diff --git a/test/unit/index-test.js b/test/unit/index-test.js index 8b7e32f..a503792 100644 --- a/test/unit/index-test.js +++ b/test/unit/index-test.js @@ -1,8 +1,8 @@ +let { join } = require('node:path') let test = require('tape') -let { join } = require('path') let proxyquire = require('proxyquire') -let lib = join(process.cwd(), 'test', 'lib') -let { capture } = require(lib) +let { capture } = require('../lib') + let sut = join(process.cwd()) let error = false @@ -11,7 +11,7 @@ function commands (p) { if (error) throw error } let begin = proxyquire(sut, { - './commands': commands + './commands': commands, }) let argv = process.argv diff --git a/test/unit/lib/index-test.js b/test/unit/lib/index-test.js index ae5fc4c..e4bd540 100644 --- a/test/unit/lib/index-test.js +++ b/test/unit/lib/index-test.js @@ -1,12 +1,10 @@ -let { join, sep } = require('path') +let { readFileSync, rmSync, writeFileSync } = require('node:fs') +let { join, sep } = require('node:path') let test = require('tape') let { sync: rm } = require('rimraf') -let { readFileSync, rmSync, writeFileSync } = require('fs') -let cwd = process.cwd() -let testLib = join(cwd, 'test', 'lib') -let { newTmpFolder } = require(testLib) -let sut = join(cwd, 'src', 'lib') -let lib = require(sut) +let { newTmpFolder } = require('../../lib') +let lib = require('../../../src/lib') + let reset = folder => rmSync(folder, { recursive: true, force: true }) test('Set up env', t => { diff --git a/test/unit/lib/mutate-arc-test.js b/test/unit/lib/mutate-arc-test.js index ac6f64a..77b1e04 100644 --- a/test/unit/lib/mutate-arc-test.js +++ b/test/unit/lib/mutate-arc-test.js @@ -1,7 +1,5 @@ -let { join } = require('path') let test = require('tape') -let sut = join(process.cwd(), 'src', 'lib', 'mutate-arc') -let mutateArc = require(sut) +let mutateArc = require('../../../src/lib/mutate-arc') test('Set up env', t => { t.plan(1) diff --git a/test/unit/lib/telemetry-test.js b/test/unit/lib/telemetry-test.js index 72195f4..5c92b9a 100644 --- a/test/unit/lib/telemetry-test.js +++ b/test/unit/lib/telemetry-test.js @@ -1,12 +1,10 @@ -let { join } = require('path') +let { join } = require('node:path') +let http = require('node:http') +let { readFileSync, rmSync, writeFileSync } = require('node:fs') let test = require('tape') -let http = require('http') -let { readFileSync, rmSync, writeFileSync } = require('fs') -let cwd = process.cwd() -let testLib = join(cwd, 'test', 'lib') -let { newTmpFolder, getPort } = require(testLib) -let sut = join(cwd, 'src', 'lib', 'telemetry') -let telemetry = require(sut) +let { newTmpFolder, getPort } = require('../../lib') +let telemetry = require('../../../src/lib/telemetry') + let reset = folder => rmSync(folder, { recursive: true, force: true }) let server = http.createServer() diff --git a/test/unit/printer/index-test.js b/test/unit/printer/index-test.js index f433394..2bf9a68 100644 --- a/test/unit/printer/index-test.js +++ b/test/unit/printer/index-test.js @@ -1,9 +1,6 @@ -let { join } = require('path') let test = require('tape') -let lib = join(process.cwd(), 'test', 'lib') -let { capture } = require(lib) -let sut = join(process.cwd(), 'src', 'printer') -let printer = require(sut) +let { capture } = require('../../lib') +let printer = require('../../../src/printer') let isTTY = process.stdout.isTTY let { env } = process diff --git a/vendor/.npmrc b/vendor/.npmrc deleted file mode 100644 index 43c97e7..0000000 --- a/vendor/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/vendor/aws-lite-dynamodb.mjs b/vendor/aws-lite-dynamodb.mjs deleted file mode 100644 index 38a8df3..0000000 --- a/vendor/aws-lite-dynamodb.mjs +++ /dev/null @@ -1,4 +0,0 @@ -import dynamo from '@aws-lite/dynamodb' -export const service = dynamo.service -export const property = dynamo.property -export const methods = dynamo.methods diff --git a/vendor/package.json b/vendor/package.json deleted file mode 100644 index a8de47c..0000000 --- a/vendor/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "esbuild": "^0.19.5" - } -} diff --git a/vendor/vendor.js b/vendor/vendor.js deleted file mode 100644 index ade329a..0000000 --- a/vendor/vendor.js +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env node - -let { execSync } = require('child_process') -let cwd = __dirname -let options = { cwd, stdio: 'inherit' } - -execSync('npm install -force --omit=dev', options) -execSync('npx esbuild ./aws-lite-dynamodb.mjs --bundle --platform=node --format=cjs --outfile=../node_modules/@architect/sandbox/src/tables/_aws-lite-dynamodb-vendor.js', options)