test-bdk-cli 0.1.15 → 0.1.17
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/commands/create.js
CHANGED
|
@@ -55,7 +55,7 @@ function registerCreate(program) {
|
|
|
55
55
|
}
|
|
56
56
|
appDirectories = collected.length ? collected : ['.'];
|
|
57
57
|
}
|
|
58
|
-
const template = opts.template || '
|
|
58
|
+
const template = opts.template || 'default';
|
|
59
59
|
const basePath = path_1.default.resolve(opts.path || '.');
|
|
60
60
|
// flatten nested array if commander wrapped variadic into single array
|
|
61
61
|
if (Array.isArray(appDirectories) && appDirectories.length === 1 && Array.isArray(appDirectories[0])) {
|
package/dist/commands/pack.js
CHANGED
|
@@ -67,7 +67,8 @@ function registerPack(program) {
|
|
|
67
67
|
const version = manifest.version || '0.0.0';
|
|
68
68
|
const fmt = (opts.format || 'zip').toLowerCase();
|
|
69
69
|
const outTarget = opts.output || './dist';
|
|
70
|
-
|
|
70
|
+
// Resolve output path relative to source directory, not current working directory
|
|
71
|
+
let outputPath = path_1.default.resolve(sourceDir, outTarget);
|
|
71
72
|
try {
|
|
72
73
|
const stat = fs_1.default.existsSync(outputPath) && fs_1.default.statSync(outputPath);
|
|
73
74
|
if (!stat || stat.isDirectory()) {
|
package/dist/commands/publish.js
CHANGED
|
@@ -26,7 +26,9 @@ function registerPublish(program) {
|
|
|
26
26
|
console.log('No package file given — running `bdk pack` to create archive...');
|
|
27
27
|
try {
|
|
28
28
|
const cliEntry = path_1.default.resolve(__dirname, '../index.js');
|
|
29
|
-
|
|
29
|
+
// Pass sourceArg or sourceDir to pack command
|
|
30
|
+
const sourceArg_str = sourceArg ? `"${sourceArg}"` : '.';
|
|
31
|
+
(0, child_process_1.execSync)(`node "${cliEntry}" pack ${sourceArg_str} --output ./dist --format zip`, { cwd: process.cwd(), stdio: 'inherit' });
|
|
30
32
|
}
|
|
31
33
|
catch (e) {
|
|
32
34
|
console.error('Automatic pack failed; please run `bdk pack` manually or provide --file');
|
package/dist/commands/test.js
CHANGED
|
@@ -10,10 +10,17 @@ function registerTest(program) {
|
|
|
10
10
|
.option('--watch', 're-run tests on file changes', false)
|
|
11
11
|
.option('--coverage', 'generate coverage report', false)
|
|
12
12
|
.action((sourceArg, opts) => {
|
|
13
|
-
const
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const cwd = path.resolve(process.cwd(), sourceArg || '.');
|
|
16
|
+
// Check if package.json exists and has test script
|
|
17
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
14
18
|
const hasPkg = (() => {
|
|
15
19
|
try {
|
|
16
|
-
|
|
20
|
+
if (!fs.existsSync(pkgPath)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const p = require(pkgPath);
|
|
17
24
|
return !!p.scripts && (p.scripts.test || p.scripts['test:watch']);
|
|
18
25
|
}
|
|
19
26
|
catch (e) {
|
|
@@ -28,7 +35,7 @@ function registerTest(program) {
|
|
|
28
35
|
// prefer npm run test -- --watch if available
|
|
29
36
|
try {
|
|
30
37
|
console.log('Running tests in watch mode...');
|
|
31
|
-
const child = (0, child_process_1.spawn)('npm', ['run', 'test', '--', '--watch'], { stdio: 'inherit', cwd:
|
|
38
|
+
const child = (0, child_process_1.spawn)('npm', ['run', 'test', '--', '--watch'], { stdio: 'inherit', cwd: cwd, shell: true });
|
|
32
39
|
child.on('exit', (code) => process.exit(code || 0));
|
|
33
40
|
}
|
|
34
41
|
catch (e) {
|
|
@@ -44,7 +51,7 @@ function registerTest(program) {
|
|
|
44
51
|
args.push('--', '--coverage');
|
|
45
52
|
}
|
|
46
53
|
console.log('Running tests...');
|
|
47
|
-
(0, child_process_1.execSync)('npm ' + args.join(' '), { stdio: 'inherit', cwd:
|
|
54
|
+
(0, child_process_1.execSync)('npm ' + args.join(' '), { stdio: 'inherit', cwd: cwd });
|
|
48
55
|
}
|
|
49
56
|
catch (e) {
|
|
50
57
|
console.error('Tests failed.');
|
package/package.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"description": "Sample app scaffolded by bdk",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"start": "echo
|
|
7
|
-
"build": "echo
|
|
8
|
-
"test": "echo
|
|
6
|
+
"start": "echo Starting app...",
|
|
7
|
+
"build": "echo Building app...",
|
|
8
|
+
"test": "echo Running tests..."
|
|
9
9
|
},
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "MIT"
|