@mondaydotcomorg/z2h-cli 0.11.5 → 0.11.6
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.d.ts.map +1 -1
- package/dist/commands/create-workspace.js +5 -1
- package/dist/esm/commands/create-workspace.d.ts.map +1 -1
- package/dist/esm/commands/create-workspace.mjs +6 -2
- package/dist/esm/index.mjs +4 -1
- package/dist/esm/util/git/repo.mjs +2 -2
- package/dist/index.js +4 -1
- package/dist/util/git/repo.js +2 -2
- package/package.json +1 -1
- package/src/commands/__tests__/create-workspace.test.ts +2 -2
- package/src/commands/create-workspace.ts +5 -1
- package/src/index.ts +4 -1
- package/src/util/git/__tests__/repo.test.ts +2 -2
- package/src/util/git/repo.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../src/commands/create-workspace.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,GAAE,sBAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../src/commands/create-workspace.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,GAAE,sBAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C7F"}
|
|
@@ -22,7 +22,11 @@ async function createWorkspaceCommand(opts = {}) {
|
|
|
22
22
|
if (await fs.pathExists(home)) {
|
|
23
23
|
const entries = await fs.readdir(home);
|
|
24
24
|
if (entries.length > 0) {
|
|
25
|
-
|
|
25
|
+
util_logger.output(`[z2h-cli] workspace already exists at ${home} — skipping`, {
|
|
26
|
+
ok: true,
|
|
27
|
+
workspace: home,
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/create-workspace.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,GAAE,sBAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/create-workspace.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,GAAE,sBAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C7F"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { pathExists, readdir, ensureDir, writeFile, copy } from 'fs-extra';
|
|
4
|
-
import { setOutputMode,
|
|
4
|
+
import { setOutputMode, output, info } from '../util/logger.mjs';
|
|
5
5
|
import { getWorkspaceHome } from '../util/workspace.mjs';
|
|
6
6
|
import { getTemplatesDir } from '../util/templates.mjs';
|
|
7
7
|
import { runYarnInstall } from '../util/npm/install.mjs';
|
|
@@ -16,7 +16,11 @@ async function createWorkspaceCommand(opts = {}) {
|
|
|
16
16
|
if (await pathExists(home)) {
|
|
17
17
|
const entries = await readdir(home);
|
|
18
18
|
if (entries.length > 0) {
|
|
19
|
-
|
|
19
|
+
output(`[z2h-cli] workspace already exists at ${home} — skipping`, {
|
|
20
|
+
ok: true,
|
|
21
|
+
workspace: home,
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
else {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -232,5 +232,8 @@ void main()
|
|
|
232
232
|
process.exit(0);
|
|
233
233
|
})
|
|
234
234
|
.catch(async (err) => {
|
|
235
|
-
|
|
235
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
236
|
+
await fail(`main failed, check you are on latest version.\nerror: ${errorMsg}`, {
|
|
237
|
+
command: 'cli-main',
|
|
238
|
+
});
|
|
236
239
|
});
|
|
@@ -81,7 +81,7 @@ async function pullAndResolve(dir, env) {
|
|
|
81
81
|
}
|
|
82
82
|
await safeBackupIfDirty(dir);
|
|
83
83
|
const info = await gatherConflictInfo(dir, gitEnv);
|
|
84
|
-
throw new GitConflictError(JSON.stringify(info));
|
|
84
|
+
throw new GitConflictError(`Pull rejected: Git conflict detected: ${JSON.stringify(info)}`);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
@@ -109,7 +109,7 @@ async function pushToRemote(dir, env) {
|
|
|
109
109
|
}
|
|
110
110
|
if (isRejected) {
|
|
111
111
|
const info = await gatherConflictInfo(dir, gitEnv);
|
|
112
|
-
throw new GitConflictError(JSON.stringify(info));
|
|
112
|
+
throw new GitConflictError(`Push rejected: Git conflict detected: ${JSON.stringify(info)}`);
|
|
113
113
|
}
|
|
114
114
|
throw err;
|
|
115
115
|
}
|
package/dist/index.js
CHANGED
|
@@ -238,5 +238,8 @@ void main()
|
|
|
238
238
|
process.exit(0);
|
|
239
239
|
})
|
|
240
240
|
.catch(async (err) => {
|
|
241
|
-
|
|
241
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
242
|
+
await util_logger.fail(`main failed, check you are on latest version.\nerror: ${errorMsg}`, {
|
|
243
|
+
command: 'cli-main',
|
|
244
|
+
});
|
|
242
245
|
});
|
package/dist/util/git/repo.js
CHANGED
|
@@ -88,7 +88,7 @@ async function pullAndResolve(dir, env) {
|
|
|
88
88
|
}
|
|
89
89
|
await safeBackupIfDirty(dir);
|
|
90
90
|
const info = await gatherConflictInfo(dir, gitEnv);
|
|
91
|
-
throw new GitConflictError(JSON.stringify(info));
|
|
91
|
+
throw new GitConflictError(`Pull rejected: Git conflict detected: ${JSON.stringify(info)}`);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
@@ -116,7 +116,7 @@ async function pushToRemote(dir, env) {
|
|
|
116
116
|
}
|
|
117
117
|
if (isRejected) {
|
|
118
118
|
const info = await gatherConflictInfo(dir, gitEnv);
|
|
119
|
-
throw new GitConflictError(JSON.stringify(info));
|
|
119
|
+
throw new GitConflictError(`Push rejected: Git conflict detected: ${JSON.stringify(info)}`);
|
|
120
120
|
}
|
|
121
121
|
throw err;
|
|
122
122
|
}
|
package/package.json
CHANGED
|
@@ -51,11 +51,11 @@ describe('create-workspace', () => {
|
|
|
51
51
|
expect(runYarnInstall).toHaveBeenCalledWith(expect.objectContaining({ cwd: tmp }));
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
it('
|
|
54
|
+
it('skips gracefully if the target dir is non-empty', async () => {
|
|
55
55
|
await ensureDir(tmp);
|
|
56
56
|
await writeJson(path.join(tmp, 'somefile.json'), { hello: 'world' });
|
|
57
57
|
|
|
58
|
-
await expect(createWorkspaceCommand()).
|
|
58
|
+
await expect(createWorkspaceCommand()).resolves.toBeUndefined();
|
|
59
59
|
expect(runYarnInstall).not.toHaveBeenCalled();
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -22,7 +22,11 @@ export async function createWorkspaceCommand(opts: CreateWorkspaceOptions = {}):
|
|
|
22
22
|
if (await pathExists(home)) {
|
|
23
23
|
const entries = await readdir(home);
|
|
24
24
|
if (entries.length > 0) {
|
|
25
|
-
|
|
25
|
+
output(`[z2h-cli] workspace already exists at ${home} — skipping`, {
|
|
26
|
+
ok: true,
|
|
27
|
+
workspace: home,
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
26
30
|
}
|
|
27
31
|
} else {
|
|
28
32
|
await ensureDir(home);
|
package/src/index.ts
CHANGED
|
@@ -258,5 +258,8 @@ void main()
|
|
|
258
258
|
process.exit(0);
|
|
259
259
|
})
|
|
260
260
|
.catch(async (err: unknown) => {
|
|
261
|
-
|
|
261
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
262
|
+
await fail(`main failed, check you are on latest version.\nerror: ${errorMsg}`, {
|
|
263
|
+
command: 'cli-main',
|
|
264
|
+
});
|
|
262
265
|
});
|
|
@@ -196,7 +196,7 @@ describe('pullAndResolve', () => {
|
|
|
196
196
|
const err = await pullAndResolve(DIR).catch(e => e);
|
|
197
197
|
|
|
198
198
|
expect(err).toBeInstanceOf(GitConflictError);
|
|
199
|
-
const info = JSON.parse(err.message);
|
|
199
|
+
const info = JSON.parse(err.message.split('Git conflict detected: ')[1]);
|
|
200
200
|
expect(info.localCommits).toEqual(['abc local commit']);
|
|
201
201
|
expect(info.remoteCommits).toEqual(['def remote commit']);
|
|
202
202
|
expect(info.conflictingFiles).toEqual(['src/index.ts']);
|
|
@@ -225,7 +225,7 @@ describe('pushToRemote', () => {
|
|
|
225
225
|
const err = await pushToRemote(DIR).catch(e => e);
|
|
226
226
|
|
|
227
227
|
expect(err).toBeInstanceOf(GitConflictError);
|
|
228
|
-
const info = JSON.parse(err.message);
|
|
228
|
+
const info = JSON.parse(err.message.split('Git conflict detected: ')[1]);
|
|
229
229
|
expect(info.localCommits).toEqual(['abc local']);
|
|
230
230
|
expect(info.remoteCommits).toEqual(['def remote']);
|
|
231
231
|
expect(info.conflictingFiles).toEqual(['file.ts']);
|
package/src/util/git/repo.ts
CHANGED
|
@@ -97,7 +97,7 @@ export async function pullAndResolve(dir: string, env?: Record<string, string>):
|
|
|
97
97
|
}
|
|
98
98
|
await safeBackupIfDirty(dir);
|
|
99
99
|
const info = await gatherConflictInfo(dir, gitEnv);
|
|
100
|
-
throw new GitConflictError(JSON.stringify(info));
|
|
100
|
+
throw new GitConflictError(`Pull rejected: Git conflict detected: ${JSON.stringify(info)}`);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -125,7 +125,7 @@ export async function pushToRemote(dir: string, env?: Record<string, string>): P
|
|
|
125
125
|
}
|
|
126
126
|
if (isRejected) {
|
|
127
127
|
const info = await gatherConflictInfo(dir, gitEnv);
|
|
128
|
-
throw new GitConflictError(JSON.stringify(info));
|
|
128
|
+
throw new GitConflictError(`Push rejected: Git conflict detected: ${JSON.stringify(info)}`);
|
|
129
129
|
}
|
|
130
130
|
throw err;
|
|
131
131
|
}
|