@mondaydotcomorg/z2h-cli 0.3.0 → 0.3.1
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-workspace.js +3 -3
- package/dist/commands/create.js +1 -1
- package/dist/esm/commands/create-workspace.mjs +3 -3
- package/dist/esm/commands/create.mjs +1 -1
- package/dist/esm/index.mjs +3 -1
- package/dist/index.js +4 -1
- package/package.json +1 -1
- package/src/commands/__tests__/create-workspace.test.ts +1 -1
- package/src/commands/__tests__/create.test.ts +1 -5
- package/src/commands/create-workspace.ts +3 -3
- package/src/commands/create.ts +1 -1
- package/src/index.ts +4 -1
|
@@ -37,7 +37,7 @@ async function createWorkspaceCommand(opts) {
|
|
|
37
37
|
if (await fsExtra.pathExists(home)) {
|
|
38
38
|
const entries = await fsExtra.readdir(home);
|
|
39
39
|
if (entries.length > 0) {
|
|
40
|
-
throw new Error(
|
|
40
|
+
throw new Error(`Workspace already exists at ${home}. Remove it and try again.`);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
@@ -66,12 +66,12 @@ async function createWorkspaceCommand(opts) {
|
|
|
66
66
|
fsExtra.copy(path__default.default.join(wsTemplatesDir, 'README.md'), path__default.default.join(home, 'README.md')),
|
|
67
67
|
fsExtra.copy(path__default.default.join(wsTemplatesDir, 'yarn-releases', 'yarn-4.5.1.cjs'), path__default.default.join(home, '.yarn', 'releases', 'yarn-4.5.1.cjs')),
|
|
68
68
|
]);
|
|
69
|
-
util_logger.info(`
|
|
69
|
+
util_logger.info(`setting up your Z2H workspace — this may take a minute...`);
|
|
70
70
|
await execa.execa('yarn', ['install'], {
|
|
71
71
|
cwd: home,
|
|
72
72
|
stdio: 'inherit',
|
|
73
73
|
});
|
|
74
|
-
util_logger.output(`
|
|
74
|
+
util_logger.output(`Your workspace is ready! 🚀 Apps will live at ${home}`, {
|
|
75
75
|
ok: true,
|
|
76
76
|
workspace: home,
|
|
77
77
|
z2hCliVersion: cliVersion,
|
package/dist/commands/create.js
CHANGED
|
@@ -95,7 +95,7 @@ async function createCommand(appName, opts) {
|
|
|
95
95
|
if (template === 'html-embed' && opts.htmlFile) {
|
|
96
96
|
await fsExtra.copy(opts.htmlFile, path__default.default.join(appDir, 'src', 'page.html'));
|
|
97
97
|
}
|
|
98
|
-
util_logger.info(`installing
|
|
98
|
+
util_logger.info(`installing dependencies for ${appName}...`);
|
|
99
99
|
await execa.execa('yarn', ['install'], {
|
|
100
100
|
cwd: workspace,
|
|
101
101
|
stdio: 'inherit',
|
|
@@ -31,7 +31,7 @@ async function createWorkspaceCommand(opts) {
|
|
|
31
31
|
if (await pathExists(home)) {
|
|
32
32
|
const entries = await readdir(home);
|
|
33
33
|
if (entries.length > 0) {
|
|
34
|
-
throw new Error(
|
|
34
|
+
throw new Error(`Workspace already exists at ${home}. Remove it and try again.`);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
@@ -60,12 +60,12 @@ async function createWorkspaceCommand(opts) {
|
|
|
60
60
|
copy(path.join(wsTemplatesDir, 'README.md'), path.join(home, 'README.md')),
|
|
61
61
|
copy(path.join(wsTemplatesDir, 'yarn-releases', 'yarn-4.5.1.cjs'), path.join(home, '.yarn', 'releases', 'yarn-4.5.1.cjs')),
|
|
62
62
|
]);
|
|
63
|
-
info(`
|
|
63
|
+
info(`setting up your Z2H workspace — this may take a minute...`);
|
|
64
64
|
await execa('yarn', ['install'], {
|
|
65
65
|
cwd: home,
|
|
66
66
|
stdio: 'inherit',
|
|
67
67
|
});
|
|
68
|
-
output(`
|
|
68
|
+
output(`Your workspace is ready! 🚀 Apps will live at ${home}`, {
|
|
69
69
|
ok: true,
|
|
70
70
|
workspace: home,
|
|
71
71
|
z2hCliVersion: cliVersion,
|
|
@@ -89,7 +89,7 @@ async function createCommand(appName, opts) {
|
|
|
89
89
|
if (template === 'html-embed' && opts.htmlFile) {
|
|
90
90
|
await copy(opts.htmlFile, path.join(appDir, 'src', 'page.html'));
|
|
91
91
|
}
|
|
92
|
-
info(`installing
|
|
92
|
+
info(`installing dependencies for ${appName}...`);
|
|
93
93
|
await execa('yarn', ['install'], {
|
|
94
94
|
cwd: workspace,
|
|
95
95
|
stdio: 'inherit',
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
1
2
|
import { Command } from 'commander';
|
|
2
3
|
import { devCommand } from './commands/dev.mjs';
|
|
3
4
|
import { buildCommand } from './commands/build.mjs';
|
|
@@ -8,6 +9,7 @@ import { createCommand } from './commands/create.mjs';
|
|
|
8
9
|
import { generateZ2HTokenCommand } from './commands/generate-z2h-token.mjs';
|
|
9
10
|
import { errorLog, fail } from './util/logger.mjs';
|
|
10
11
|
|
|
12
|
+
const { version } = createRequire(import.meta.url)('../package.json');
|
|
11
13
|
async function main() {
|
|
12
14
|
const program = new Command();
|
|
13
15
|
program
|
|
@@ -24,7 +26,7 @@ async function main() {
|
|
|
24
26
|
' 1 user-resolvable error (bad cwd, invalid package.json, lock held)',
|
|
25
27
|
' 2 system error (yarn install or trident build failed)',
|
|
26
28
|
].join('\n'))
|
|
27
|
-
.version(
|
|
29
|
+
.version(version);
|
|
28
30
|
program
|
|
29
31
|
.command('build')
|
|
30
32
|
.description('Build the consumer into its .zth/ shadow and copy artifacts to ./build/')
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const node_module = require('node:module');
|
|
1
2
|
const commander = require('commander');
|
|
2
3
|
const commands_dev = require('./commands/dev.js');
|
|
3
4
|
const commands_build = require('./commands/build.js');
|
|
@@ -8,6 +9,8 @@ const commands_create = require('./commands/create.js');
|
|
|
8
9
|
const commands_generateZ2hToken = require('./commands/generate-z2h-token.js');
|
|
9
10
|
const util_logger = require('./util/logger.js');
|
|
10
11
|
|
|
12
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
13
|
+
const { version } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)))('../package.json');
|
|
11
14
|
async function main() {
|
|
12
15
|
const program = new commander.Command();
|
|
13
16
|
program
|
|
@@ -24,7 +27,7 @@ async function main() {
|
|
|
24
27
|
' 1 user-resolvable error (bad cwd, invalid package.json, lock held)',
|
|
25
28
|
' 2 system error (yarn install or trident build failed)',
|
|
26
29
|
].join('\n'))
|
|
27
|
-
.version(
|
|
30
|
+
.version(version);
|
|
28
31
|
program
|
|
29
32
|
.command('build')
|
|
30
33
|
.description('Build the consumer into its .zth/ shadow and copy artifacts to ./build/')
|
package/package.json
CHANGED
|
@@ -57,7 +57,7 @@ describe('create-workspace', () => {
|
|
|
57
57
|
await ensureDir(tmp);
|
|
58
58
|
await writeJson(path.join(tmp, 'somefile.json'), { hello: 'world' });
|
|
59
59
|
|
|
60
|
-
await expect(createWorkspaceCommand({})).rejects.toThrow(/
|
|
60
|
+
await expect(createWorkspaceCommand({})).rejects.toThrow(/Workspace already exists/);
|
|
61
61
|
expect(execa).not.toHaveBeenCalled();
|
|
62
62
|
});
|
|
63
63
|
|
|
@@ -77,11 +77,7 @@ describe('create', () => {
|
|
|
77
77
|
expect(content).toContain('export default function DemoApp()');
|
|
78
78
|
expect(content).not.toContain('__APP_COMPONENT__');
|
|
79
79
|
|
|
80
|
-
expect(execa).toHaveBeenCalledWith(
|
|
81
|
-
'yarn',
|
|
82
|
-
expect.arrayContaining(['install']),
|
|
83
|
-
expect.objectContaining({ cwd: tmp })
|
|
84
|
-
);
|
|
80
|
+
expect(execa).toHaveBeenCalledWith('yarn', ['install'], expect.any(Object));
|
|
85
81
|
});
|
|
86
82
|
|
|
87
83
|
it('scaffolds an html-embed app and copies the html file', async () => {
|
|
@@ -38,7 +38,7 @@ export async function createWorkspaceCommand(opts: CreateWorkspaceOptions): Prom
|
|
|
38
38
|
if (await pathExists(home)) {
|
|
39
39
|
const entries = await readdir(home);
|
|
40
40
|
if (entries.length > 0) {
|
|
41
|
-
throw new Error(
|
|
41
|
+
throw new Error(`Workspace already exists at ${home}. Remove it and try again.`);
|
|
42
42
|
}
|
|
43
43
|
} else {
|
|
44
44
|
await ensureDir(home);
|
|
@@ -72,13 +72,13 @@ export async function createWorkspaceCommand(opts: CreateWorkspaceOptions): Prom
|
|
|
72
72
|
),
|
|
73
73
|
]);
|
|
74
74
|
|
|
75
|
-
info(`
|
|
75
|
+
info(`setting up your Z2H workspace — this may take a minute...`);
|
|
76
76
|
await execa('yarn', ['install'], {
|
|
77
77
|
cwd: home,
|
|
78
78
|
stdio: 'inherit',
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
output(`
|
|
81
|
+
output(`Your workspace is ready! 🚀 Apps will live at ${home}`, {
|
|
82
82
|
ok: true,
|
|
83
83
|
workspace: home,
|
|
84
84
|
z2hCliVersion: cliVersion,
|
package/src/commands/create.ts
CHANGED
|
@@ -115,7 +115,7 @@ export async function createCommand(appName: string, opts: CreateOptions): Promi
|
|
|
115
115
|
await copy(opts.htmlFile, path.join(appDir, 'src', 'page.html'));
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
info(`installing
|
|
118
|
+
info(`installing dependencies for ${appName}...`);
|
|
119
119
|
await execa('yarn', ['install'], {
|
|
120
120
|
cwd: workspace,
|
|
121
121
|
stdio: 'inherit',
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
1
2
|
import { Command } from 'commander';
|
|
2
3
|
import { devCommand } from './commands/dev';
|
|
3
4
|
import { buildCommand } from './commands/build';
|
|
@@ -8,6 +9,8 @@ import { createCommand } from './commands/create';
|
|
|
8
9
|
import { generateZ2HTokenCommand } from './commands/generate-z2h-token';
|
|
9
10
|
import { errorLog, fail } from './util/logger';
|
|
10
11
|
|
|
12
|
+
const { version } = createRequire(import.meta.url)('../package.json') as { version: string };
|
|
13
|
+
|
|
11
14
|
async function main(): Promise<void> {
|
|
12
15
|
const program = new Command();
|
|
13
16
|
program
|
|
@@ -26,7 +29,7 @@ async function main(): Promise<void> {
|
|
|
26
29
|
' 2 system error (yarn install or trident build failed)',
|
|
27
30
|
].join('\n')
|
|
28
31
|
)
|
|
29
|
-
.version(
|
|
32
|
+
.version(version);
|
|
30
33
|
|
|
31
34
|
program
|
|
32
35
|
.command('build')
|