@startupjs/cli 0.56.0-alpha.1 → 0.56.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,21 +1,29 @@
1
1
  # startupjs cli
2
2
 
3
- > start, watch and build startupjs project
4
-
5
- ## Installation
3
+ ## Usage
6
4
 
7
- ```sh
8
- yarn add @startupjs/cli
5
+ ```
6
+ npx startupjs <command> [options]
9
7
  ```
10
8
 
11
- ## Usage
9
+ ## Commands
12
10
 
13
- ```sh
14
- npx startupjs init myapp --version=next && cd myapp
15
- ```
11
+ ### `install`
12
+
13
+ Run `npx startupjs install --help` for a full manual
14
+
15
+ ### `build`
16
+
17
+ Build web bundle for production usage
18
+
19
+ ### `start-production`
20
+
21
+ Start production node server with production web build
22
+
23
+ (run this after `npx startupjs build`)
16
24
 
17
- ## License
25
+ ### `init-pm`, `pr`, `task <github_issue_number>`
18
26
 
19
- MIT
27
+ Project management helper commands.
20
28
 
21
- (c) Decision Mapper - http://decisionmapper.com
29
+ See [`@startupjs/pm` readme](../pm) for documentation on them.
@@ -0,0 +1,10 @@
1
+ import { $ } from 'execa'
2
+
3
+ export const name = 'build'
4
+ export const description = 'Build web bundle for production usage'
5
+
6
+ export async function action ({ inspect }) {
7
+ await $({ stdio: 'inherit' })`\
8
+ npx expo export -p web \
9
+ `
10
+ }
@@ -0,0 +1,7 @@
1
+ export * as initPm from './pm/init-pm.js'
2
+ export * as pr from './pm/pr.js'
3
+ export * as task from './pm/task.js'
4
+ export * as postinstall from './postinstall.js'
5
+ export * as startProduction from './start-production.js'
6
+ export * as build from './build.js'
7
+ export * as install from 'create-startupjs/install'
@@ -0,0 +1,30 @@
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ import { $ } from 'execa'
4
+ import { getScriptsPath } from './utils.js'
5
+
6
+ export const name = 'init-pm'
7
+ export const description = 'Create a new project on github from template'
8
+
9
+ export async function action () {
10
+ const scriptsPath = getScriptsPath()
11
+
12
+ // TODO: maybe change this to use 'sh' binary directly and remove `shell: true`
13
+ await $({ shell: true, stdio: 'inherit' })`\
14
+ ${scriptsPath} init-pm \
15
+ `
16
+
17
+ const packageJSONPath = path.join(process.cwd(), 'package.json')
18
+ const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath).toString())
19
+
20
+ packageJSON.scripts = {
21
+ ...packageJSON.scripts,
22
+ task: 'npx startupjs task',
23
+ pr: 'npx startupjs pr'
24
+ }
25
+
26
+ fs.writeFileSync(
27
+ packageJSONPath,
28
+ `${JSON.stringify(packageJSON, null, 2)}\n`
29
+ )
30
+ }
@@ -0,0 +1,12 @@
1
+ import { $ } from 'execa'
2
+ import { getScriptsPath } from './utils.js'
3
+
4
+ export const name = 'pr [issueNumber]'
5
+ export const description = 'Make PR for this task (or re-request review if it already exists)'
6
+
7
+ export async function action (issueNumber) {
8
+ const scriptsPath = getScriptsPath()
9
+ await $({ shell: true, stdio: 'inherit' })`\
10
+ ${scriptsPath} pr ${issueNumber} \
11
+ `
12
+ }
@@ -0,0 +1,12 @@
1
+ import { $ } from 'execa'
2
+ import { getScriptsPath } from './utils.js'
3
+
4
+ export const name = 'task <issueNumber>'
5
+ export const description = 'Create a task branch (or just switch to it if it already exists)'
6
+
7
+ export async function action (issueNumber) {
8
+ const scriptsPath = getScriptsPath()
9
+ await $({ shell: true, stdio: 'inherit' })`\
10
+ ${scriptsPath} task ${issueNumber} \
11
+ `
12
+ }
@@ -0,0 +1,8 @@
1
+ import { join, dirname } from 'path'
2
+ import { createRequire } from 'module'
3
+
4
+ const require = createRequire(import.meta.url)
5
+
6
+ export function getScriptsPath () {
7
+ return join(dirname(require.resolve('@startupjs/pm')), 'scripts.sh')
8
+ }
@@ -0,0 +1,17 @@
1
+ import { $ } from 'execa'
2
+ import { join, dirname, relative } from 'path'
3
+ import { createRequire } from 'module'
4
+
5
+ const require = createRequire(import.meta.url)
6
+
7
+ export const name = 'postinstall'
8
+ export const description = 'Run startupjs postinstall scripts'
9
+
10
+ export async function action () {
11
+ let patchesPath = join(dirname(require.resolve('@startupjs/patches')), 'patches')
12
+ // patch-package requires the path to be relative
13
+ patchesPath = relative(process.cwd(), patchesPath)
14
+ await $({ stdio: 'inherit' })`\
15
+ npx patch-package --patch-dir ${patchesPath} \
16
+ `
17
+ }
@@ -0,0 +1,21 @@
1
+ import { $ } from 'execa'
2
+
3
+ export const name = 'start-production'
4
+ export const description = 'Start production node server with production web build'
5
+ export const options = [{
6
+ name: '-i, --inspect',
7
+ description: 'Enable NodeJS inspector agent'
8
+ }]
9
+
10
+ export async function action ({ inspect } = {}) {
11
+ await $({
12
+ stdio: 'inherit',
13
+ env: { NODE_ENV: 'production' }
14
+ })`\
15
+ node \
16
+ --experimental-detect-module \
17
+ ${inspect ? '--inspect' : []} \
18
+ --import=startupjs/nodeRegister \
19
+ -e import('startupjs/startServer') \
20
+ `
21
+ }