Skip to content

Commit

Permalink
Binary deprecation notice (#182)
Browse files Browse the repository at this point in the history
* simple banner for deprecation

* only print deprecation if tty

* Update binary-config

* copy folder with pkg compat
  • Loading branch information
tbeseda authored Apr 16, 2024
1 parent 142f638 commit 7cf70df
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 33 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion scripts/binary-config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 29 additions & 25 deletions src/commands/new/action.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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')
}
Expand Down Expand Up @@ -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')
Expand Down
8 changes: 8 additions & 0 deletions src/pkg-index.js
Original file line number Diff line number Diff line change
@@ -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')()

0 comments on commit 7cf70df

Please sign in to comment.