@mondaydotcomorg/z2h-cli 0.6.1 → 0.7.0

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.
@@ -1,6 +1,9 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { readFileSync } from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
3
5
  import { Command } from 'commander';
6
+ import { execa } from 'execa';
4
7
  import { devCommand } from './commands/dev.mjs';
5
8
  import { buildCommand } from './commands/build.mjs';
6
9
  import { cleanCommand } from './commands/clean.mjs';
@@ -9,10 +12,19 @@ import { createWorkspaceCommand } from './commands/create-workspace.mjs';
9
12
  import { createCommand } from './commands/create.mjs';
10
13
  import { generateZ2HTokenCommand } from './commands/generate-z2h-token.mjs';
11
14
  import { migrateCommand } from './commands/migrate.mjs';
12
- import { errorLog, fail } from './util/logger.mjs';
15
+ import { errorLog, fail, getOutputMode } from './util/logger.mjs';
13
16
  import { trackDuration } from './util/tracker.mjs';
14
17
 
15
18
  const { version } = createRequire(import.meta.url)('../package.json');
19
+ const UPDATE_SCRIPT = path.join(os.homedir(), 'Development', 'bigbrain-z2h', 'z2h', 'setup', 'update.sh');
20
+ function selfUpdate() {
21
+ try {
22
+ execa('bash', [UPDATE_SCRIPT], { detached: true, stdio: 'ignore' }).unref();
23
+ }
24
+ catch (err) {
25
+ errorLog(`Z2H auto-update failed to start: ${err.message}`);
26
+ }
27
+ }
16
28
  function getCwdAppName() {
17
29
  try {
18
30
  return JSON.parse(readFileSync('package.json', 'utf8')).name;
@@ -149,6 +161,11 @@ async function main() {
149
161
  }
150
162
  void main()
151
163
  .then(() => {
164
+ // After the command succeeds, kick off update in the background.
165
+ // Human mode only — never surprise machine (--json) consumers.
166
+ if (getOutputMode() === 'human') {
167
+ selfUpdate();
168
+ }
152
169
  process.exit(0);
153
170
  })
154
171
  .catch((err) => {
@@ -1 +1 @@
1
- {"version":3,"file":"auto-migrate.d.ts","sourceRoot":"","sources":["../../../src/migrations/auto-migrate.ts"],"names":[],"mappings":"AAsHA,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA+FnF"}
1
+ {"version":3,"file":"auto-migrate.d.ts","sourceRoot":"","sources":["../../../src/migrations/auto-migrate.ts"],"names":[],"mappings":"AAsHA,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAkGnF"}
@@ -107,7 +107,10 @@ async function autoMigrate(cliVersion, dryRun = false) {
107
107
  return;
108
108
  }
109
109
  const migrationsJson = (await readJson(migrationsJsonPath));
110
- // Filter to pending migrations (version > lastVersion AND <= cliVersion)
110
+ // Filter to pending migrations (version > lastVersion AND <= cliVersion).
111
+ // CONVENTION: a migration's `version` field must equal the CLI release it
112
+ // ships with (not the feature branch version). This ensures the `gt` check
113
+ // always catches a migration on the exact upgrade that introduces it.
111
114
  const pending = Object.entries(migrationsJson.migrations)
112
115
  .filter(([, entry]) => semver.gt(entry.version, lastVersion) && semver.lte(entry.version, cliVersion))
113
116
  .sort(([, a], [, b]) => semver.compare(a.version, b.version));
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  const node_module = require('node:module');
2
2
  const fs = require('node:fs');
3
+ const os = require('node:os');
4
+ const path = require('node:path');
3
5
  const commander = require('commander');
6
+ const execa = require('execa');
4
7
  const commands_dev = require('./commands/dev.js');
5
8
  const commands_build = require('./commands/build.js');
6
9
  const commands_clean = require('./commands/clean.js');
@@ -13,7 +16,21 @@ const util_logger = require('./util/logger.js');
13
16
  const util_tracker = require('./util/tracker.js');
14
17
 
15
18
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
19
+ const _interopDefault = e => e && e.__esModule ? e : { default: e };
20
+
21
+ const os__default = /*#__PURE__*/_interopDefault(os);
22
+ const path__default = /*#__PURE__*/_interopDefault(path);
23
+
16
24
  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');
25
+ const UPDATE_SCRIPT = path__default.default.join(os__default.default.homedir(), 'Development', 'bigbrain-z2h', 'z2h', 'setup', 'update.sh');
26
+ function selfUpdate() {
27
+ try {
28
+ execa.execa('bash', [UPDATE_SCRIPT], { detached: true, stdio: 'ignore' }).unref();
29
+ }
30
+ catch (err) {
31
+ util_logger.errorLog(`Z2H auto-update failed to start: ${err.message}`);
32
+ }
33
+ }
17
34
  function getCwdAppName() {
18
35
  try {
19
36
  return JSON.parse(fs.readFileSync('package.json', 'utf8')).name;
@@ -150,6 +167,11 @@ async function main() {
150
167
  }
151
168
  void main()
152
169
  .then(() => {
170
+ // After the command succeeds, kick off update in the background.
171
+ // Human mode only — never surprise machine (--json) consumers.
172
+ if (util_logger.getOutputMode() === 'human') {
173
+ selfUpdate();
174
+ }
153
175
  process.exit(0);
154
176
  })
155
177
  .catch((err) => {
@@ -1 +1 @@
1
- {"version":3,"file":"auto-migrate.d.ts","sourceRoot":"","sources":["../../src/migrations/auto-migrate.ts"],"names":[],"mappings":"AAsHA,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA+FnF"}
1
+ {"version":3,"file":"auto-migrate.d.ts","sourceRoot":"","sources":["../../src/migrations/auto-migrate.ts"],"names":[],"mappings":"AAsHA,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAkGnF"}
@@ -115,7 +115,10 @@ async function autoMigrate(cliVersion, dryRun = false) {
115
115
  return;
116
116
  }
117
117
  const migrationsJson = (await fsExtra.readJson(migrationsJsonPath));
118
- // Filter to pending migrations (version > lastVersion AND <= cliVersion)
118
+ // Filter to pending migrations (version > lastVersion AND <= cliVersion).
119
+ // CONVENTION: a migration's `version` field must equal the CLI release it
120
+ // ships with (not the feature branch version). This ensures the `gt` check
121
+ // always catches a migration on the exact upgrade that introduces it.
119
122
  const pending = Object.entries(migrationsJson.migrations)
120
123
  .filter(([, entry]) => semver__default.default.gt(entry.version, lastVersion) && semver__default.default.lte(entry.version, cliVersion))
121
124
  .sort(([, a], [, b]) => semver__default.default.compare(a.version, b.version));
package/migrations.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "migrate": "./dist/migrations/002-remove-z2h-cli-from-workspace-deps"
12
12
  },
13
13
  "npm-broker-scope-split": {
14
- "version": "0.6.0",
14
+ "version": "0.6.1",
15
15
  "description": "Rewrite workspace .yarnrc.yml/.npmrc from ${NPM_TOKEN} to the @mondaydotcomorg broker scope-split",
16
16
  "migrate": "./dist/migrations/003-npm-broker-scope-split"
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-cli",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "bin": "./bin/z2h-cli.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { readFileSync } from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
3
5
  import { Command } from 'commander';
6
+ import { execa } from 'execa';
4
7
  import { devCommand } from './commands/dev';
5
8
  import { buildCommand } from './commands/build';
6
9
  import { cleanCommand } from './commands/clean';
@@ -9,11 +12,21 @@ import { createWorkspaceCommand } from './commands/create-workspace';
9
12
  import { createCommand } from './commands/create';
10
13
  import { generateZ2HTokenCommand } from './commands/generate-z2h-token';
11
14
  import { migrateCommand } from './commands/migrate';
12
- import { errorLog, fail } from './util/logger';
15
+ import { errorLog, fail, getOutputMode } from './util/logger';
13
16
  import { trackDuration } from './util/tracker';
14
17
 
15
18
  const { version } = createRequire(import.meta.url)('../package.json') as { version: string };
16
19
 
20
+ const UPDATE_SCRIPT = path.join(os.homedir(), 'Development', 'bigbrain-z2h', 'z2h', 'setup', 'update.sh');
21
+
22
+ function selfUpdate(): void {
23
+ try {
24
+ execa('bash', [UPDATE_SCRIPT], { detached: true, stdio: 'ignore' }).unref();
25
+ } catch (err) {
26
+ errorLog(`Z2H auto-update failed to start: ${(err as Error).message}`);
27
+ }
28
+ }
29
+
17
30
  function getCwdAppName(): string | undefined {
18
31
  try {
19
32
  return (JSON.parse(readFileSync('package.json', 'utf8')) as { name?: string }).name;
@@ -156,6 +169,11 @@ async function main(): Promise<void> {
156
169
 
157
170
  void main()
158
171
  .then(() => {
172
+ // After the command succeeds, kick off update in the background.
173
+ // Human mode only — never surprise machine (--json) consumers.
174
+ if (getOutputMode() === 'human') {
175
+ selfUpdate();
176
+ }
159
177
  process.exit(0);
160
178
  })
161
179
  .catch((err: unknown) => {
@@ -144,7 +144,10 @@ export async function autoMigrate(cliVersion: string, dryRun = false): Promise<v
144
144
 
145
145
  const migrationsJson = (await readJson(migrationsJsonPath)) as MigrationsJson;
146
146
 
147
- // Filter to pending migrations (version > lastVersion AND <= cliVersion)
147
+ // Filter to pending migrations (version > lastVersion AND <= cliVersion).
148
+ // CONVENTION: a migration's `version` field must equal the CLI release it
149
+ // ships with (not the feature branch version). This ensures the `gt` check
150
+ // always catches a migration on the exact upgrade that introduces it.
148
151
  const pending = Object.entries(migrationsJson.migrations)
149
152
  .filter(([, entry]) => semver.gt(entry.version, lastVersion) && semver.lte(entry.version, cliVersion))
150
153
  .sort(([, a], [, b]) => semver.compare(a.version, b.version));