From 7cf70dfebbcb323824b74766c003d3f1fbb1b2bf Mon Sep 17 00:00:00 2001 From: Taylor Beseda Date: Tue, 16 Apr 2024 11:21:49 -0600 Subject: [PATCH] Binary deprecation notice (#182) * simple banner for deprecation * only print deprecation if tty * Update binary-config * copy folder with pkg compat --- package.json | 14 +++++----- scripts/binary-config | 2 +- src/commands/new/action.js | 54 ++++++++++++++++++++------------------ src/pkg-index.js | 8 ++++++ 4 files changed, 45 insertions(+), 33 deletions(-) create mode 100755 src/pkg-index.js diff --git a/package.json b/package.json index 92e246c..d99eb78 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,9 @@ }, "scripts": { "test": "npm run lint && npm run coverage && npm run test:integration && npm run test:integration:slow", - "test:unit": "cross-env tape 'test/unit/**/*-test.js' | tap-arc", - "test:integration": "cross-env NODE_ENV=testing tape 'test/integration/**/*-test.js' | tap-arc", - "test:integration:slow": "cross-env NODE_ENV=testing tape 'test/integration/**/*-test-slow.js' | tap-arc", + "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", @@ -22,13 +22,13 @@ }, "license": "Apache-2.0", "dependencies": { - "@architect/inventory": "4.0.3", + "@architect/inventory": "4.0.4", "@architect/parser": "6.0.3", - "@architect/utils": "4.0.3", + "@architect/utils": "4.0.4", "@begin/api": "1.9.4", "@colors/colors": "1.6.0", - "@enhance/cli": "1.1.0", - "@enhance/starter-project": "7.0.1", + "@enhance/cli": "1.2.0", + "@enhance/starter-project": "7.0.2", "adm-zip": "0.5.10", "enquirer": "2.4.1", "minimist": "1.2.8", diff --git a/scripts/binary-config b/scripts/binary-config index dc9520a..89ca0f7 100755 --- a/scripts/binary-config +++ b/scripts/binary-config @@ -16,7 +16,7 @@ console.log(`Building Begin... (DEPLOY: ${DEPLOY}, BUILD_ALL: ${BUILD_ALL})`) let config = { name: 'begin', bin: { - cli: '../src/index.js' + cli: '../src/pkg-index.js' }, pkg: { // Don't manually include runtimes/deno.js in scripts, as it fails on pkg#997 diff --git a/src/commands/new/action.js b/src/commands/new/action.js index 6f6e170..991afed 100644 --- a/src/commands/new/action.js +++ b/src/commands/new/action.js @@ -1,13 +1,6 @@ - -function shortenPath (filePath) { - let { sep } = require('path') - let packageName = `@enhance${sep}starter-project${sep}` - return filePath.substring(filePath.lastIndexOf(packageName) + packageName.length) -} - module.exports = async function (params) { - let { existsSync, mkdirSync, readFileSync } = require('fs') - let { isAbsolute, join, normalize, sep } = require('path') + let { lstatSync, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync } = require('fs') + let { isAbsolute, join, normalize } = require('path') let { args } = params let utils = require('../../lib') @@ -38,7 +31,7 @@ module.exports = async function (params) { } // App name (optional) - let appName = args.name || args.n ? args.name || args.n : 'begin-app' + let appName = args.name || args.n ? args.name || args.n : 'begin-app' if (!looseName.test(appName)) { return error('invalid_appname') } @@ -66,22 +59,33 @@ module.exports = async function (params) { // Write the new Arc project manifest writeFile(p('.arc'), arc) - // Create starter app folders - mkdirSync(p(`app${sep}pages`), { recursive: true }) - mkdirSync(p('public'), { recursive: true }) - // Starter project files - // when you install @enhance/starter-project the manifest.json file is created - // so we can read it instead of having to maintain a file list here. - let manifestPath = join(nodeModules, '@enhance', 'starter-project', 'manifest.json') - let starterProjectManifest = JSON.parse(readFileSync(manifestPath)) - - // Create starter files - starterProjectManifest.fileList.forEach(file => { - let input = join(nodeModules, file) - let data = readFileSync(input) - writeFile(p(shortenPath(input)), data) - }) + 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 }) // Write .gitignore let gitIgnoreTemplate = join(nodeModules, '@enhance', 'starter-project', 'template.gitignore') diff --git a/src/pkg-index.js b/src/pkg-index.js new file mode 100755 index 0000000..2845af5 --- /dev/null +++ b/src/pkg-index.js @@ -0,0 +1,8 @@ +#! /usr/bin/env node + +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')()