@xylabs/ts-scripts-yarn3 2.7.0-rc.22 → 2.7.0-rc.25
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/dist/cjs/actions/compile.d.ts +1 -1
- package/dist/cjs/actions/compile.d.ts.map +1 -1
- package/dist/cjs/actions/compile.js +5 -3
- package/dist/cjs/actions/compile.js.map +1 -1
- package/dist/cjs/actions/dead.js +1 -1
- package/dist/cjs/actions/dead.js.map +1 -1
- package/dist/cjs/actions/license.d.ts +1 -1
- package/dist/cjs/actions/license.d.ts.map +1 -1
- package/dist/cjs/actions/license.js +1 -1
- package/dist/cjs/actions/license.js.map +1 -1
- package/dist/cjs/bin/xy.js +13 -3
- package/dist/cjs/bin/xy.js.map +1 -1
- package/dist/cjs/lib/index.d.ts +1 -0
- package/dist/cjs/lib/index.d.ts.map +1 -1
- package/dist/cjs/lib/index.js +1 -0
- package/dist/cjs/lib/index.js.map +1 -1
- package/dist/cjs/lib/runStepsAsync.d.ts +4 -0
- package/dist/cjs/lib/runStepsAsync.d.ts.map +1 -0
- package/dist/cjs/lib/runStepsAsync.js +47 -0
- package/dist/cjs/lib/runStepsAsync.js.map +1 -0
- package/dist/esm/actions/compile.d.ts +1 -1
- package/dist/esm/actions/compile.d.ts.map +1 -1
- package/dist/esm/actions/compile.js +4 -3
- package/dist/esm/actions/compile.js.map +1 -1
- package/dist/esm/actions/dead.js +1 -1
- package/dist/esm/actions/dead.js.map +1 -1
- package/dist/esm/actions/license.d.ts +1 -1
- package/dist/esm/actions/license.d.ts.map +1 -1
- package/dist/esm/actions/license.js +1 -1
- package/dist/esm/actions/license.js.map +1 -1
- package/dist/esm/bin/xy.js +12 -3
- package/dist/esm/bin/xy.js.map +1 -1
- package/dist/esm/lib/index.d.ts +1 -0
- package/dist/esm/lib/index.d.ts.map +1 -1
- package/dist/esm/lib/index.js +1 -0
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/runStepsAsync.d.ts +4 -0
- package/dist/esm/lib/runStepsAsync.d.ts.map +1 -0
- package/dist/esm/lib/runStepsAsync.js +45 -0
- package/dist/esm/lib/runStepsAsync.js.map +1 -0
- package/dist/tsconfig.build.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.build.esm.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/actions/compile.ts +6 -3
- package/src/actions/dead.ts +1 -1
- package/src/actions/license.ts +1 -1
- package/src/bin/xy.ts +16 -3
- package/src/lib/index.ts +1 -0
- package/src/lib/runStepsAsync.ts +46 -0
package/src/bin/xy.ts
CHANGED
|
@@ -2,7 +2,7 @@ import yargs from 'yargs'
|
|
|
2
2
|
// eslint-disable-next-line import/no-internal-modules
|
|
3
3
|
import { hideBin } from 'yargs/helpers'
|
|
4
4
|
|
|
5
|
-
import { build, compile, clean, copyAssets, cycle, dead, lint, deps, fix, genDocs, gitlint, gitlintFix, lintFast, lintProfile, rebuild, relint, reinstall, sonar, test, tsconfigGen, tsconfigGenClean, up, updo, yarn3Only } from '../actions'
|
|
5
|
+
import { build, compile, clean, copyAssets, cycle, dead, lint, deps, fix, genDocs, gitlint, gitlintFix, lintFast, lintProfile, rebuild, relint, reinstall, sonar, test, tsconfigGen, tsconfigGenClean, up, updo, yarn3Only, license } from '../actions'
|
|
6
6
|
|
|
7
7
|
const parseOptions = async (y: typeof yargs) => {
|
|
8
8
|
return await y.option('verbose', {
|
|
@@ -63,9 +63,9 @@ const run = async () => {
|
|
|
63
63
|
describe: 'Specific package to compile'
|
|
64
64
|
})
|
|
65
65
|
},
|
|
66
|
-
(argv) => {
|
|
66
|
+
async (argv) => {
|
|
67
67
|
if (options.verbose) console.info(`Compiling: ${(argv.package ?? 'all')}`)
|
|
68
|
-
process.exitCode = compile({target: options.target as ('esm' | 'cjs')})
|
|
68
|
+
process.exitCode = await compile({target: options.target as ('esm' | 'cjs')})
|
|
69
69
|
},
|
|
70
70
|
)
|
|
71
71
|
.command(
|
|
@@ -81,6 +81,19 @@ const run = async () => {
|
|
|
81
81
|
process.exitCode = clean()
|
|
82
82
|
},
|
|
83
83
|
)
|
|
84
|
+
.command(
|
|
85
|
+
'license [package]',
|
|
86
|
+
'License - Check licenses of dependencies',
|
|
87
|
+
(yargs) => {
|
|
88
|
+
return yargs.positional('package', {
|
|
89
|
+
describe: 'Specific package to check'
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
(argv) => {
|
|
93
|
+
if (options.verbose) console.info(`License: ${(argv.package ?? 'all')}`)
|
|
94
|
+
process.exitCode = license()
|
|
95
|
+
},
|
|
96
|
+
)
|
|
84
97
|
.command(
|
|
85
98
|
'copy-assets [package]',
|
|
86
99
|
'Copy Assets - Copy the assets from src to dist',
|
package/src/lib/index.ts
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { spawn } from 'child_process'
|
|
3
|
+
import { existsSync } from 'fs'
|
|
4
|
+
|
|
5
|
+
import { ScriptStep } from './runSteps'
|
|
6
|
+
|
|
7
|
+
export const runStepAsync = (step: ScriptStep, exitOnFail = true, message?: string) => {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const [command, args, config] = step
|
|
10
|
+
if (message) {
|
|
11
|
+
console.log(chalk.gray(message))
|
|
12
|
+
}
|
|
13
|
+
const argList = Array.isArray(args) ? args : args.split(' ')
|
|
14
|
+
if (command === 'node' && !existsSync(argList[0])) {
|
|
15
|
+
throw Error(`File not found [${argList[0]}]`)
|
|
16
|
+
}
|
|
17
|
+
spawn(command, Array.isArray(args) ? args : args.split(' '), {
|
|
18
|
+
...config,
|
|
19
|
+
shell: true,
|
|
20
|
+
stdio: 'inherit',
|
|
21
|
+
}).on('close', (code) => {
|
|
22
|
+
if (code) {
|
|
23
|
+
if (exitOnFail) {
|
|
24
|
+
process.exit(code)
|
|
25
|
+
}
|
|
26
|
+
reject(code)
|
|
27
|
+
} else {
|
|
28
|
+
resolve(0)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const runStepsAsync = async (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]) => {
|
|
35
|
+
try {
|
|
36
|
+
const pkgName = process.env.npm_package_name
|
|
37
|
+
console.log(chalk.green(`${name} [${pkgName}]`))
|
|
38
|
+
for (let i = 0; i < steps.length; i++) {
|
|
39
|
+
await runStepAsync(steps[i], exitOnFail, messages?.[i])
|
|
40
|
+
}
|
|
41
|
+
return 0
|
|
42
|
+
} catch (ex) {
|
|
43
|
+
console.log(ex)
|
|
44
|
+
process.exit(-1)
|
|
45
|
+
}
|
|
46
|
+
}
|