@git.zone/cli 8.11.0 → 9.0.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.
- package/assets/templates/{asset_deno_binary_installer → asset_binary_installer}/install.sh +2 -2
- package/assets/templates/{asset_deno_binary_postinstall → asset_binary_postinstall}/bin/wrapper.js +2 -2
- package/assets/templates/{asset_deno_binary_postinstall → asset_binary_postinstall}/scripts/install-binary.js +2 -2
- package/assets/templates/asset_binary_release_gitea/.gitea/workflows/release.yml +180 -0
- package/assets/templates/asset_tspack_release_gitea/.gitea/workflows/release.yml +7 -4
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/helpers.managedassets.d.ts +44 -0
- package/dist_ts/helpers.managedassets.js +166 -0
- package/dist_ts/helpers.ownerscopes.d.ts +3 -15
- package/dist_ts/helpers.ownerscopes.js +4 -16
- package/dist_ts/helpers.packagefiles.d.ts +2 -1
- package/dist_ts/helpers.packagefiles.js +7 -4
- package/dist_ts/helpers.sealedrelease.js +3 -3
- package/dist_ts/helpers.tssea.d.ts +11 -0
- package/dist_ts/helpers.tssea.js +81 -0
- package/dist_ts/helpers.workflow.d.ts +0 -3
- package/dist_ts/helpers.workflow.js +7 -19
- package/dist_ts/index.d.ts +1 -1
- package/dist_ts/index.js +2 -2
- package/dist_ts/mod_commit/mod.helpers.d.ts +8 -21
- package/dist_ts/mod_commit/mod.helpers.js +32 -83
- package/dist_ts/mod_commit/mod.ui.js +1 -5
- package/dist_ts/mod_config/index.js +41 -33
- package/dist_ts/mod_format/formatters/assets.formatter.js +42 -92
- package/dist_ts/mod_format/formatters/packagejson.formatter.js +3 -3
- package/dist_ts/mod_format/index.js +30 -11
- package/dist_ts/mod_format/interfaces.format.js +1 -2
- package/dist_ts/mod_release/helpers.releasepreparation.d.ts +6 -14
- package/dist_ts/mod_release/helpers.releasepreparation.js +27 -53
- package/dist_ts/mod_release/index.js +9 -10
- package/dist_ts/mod_services/classes.serviceconfiguration.d.ts +2 -2
- package/dist_ts/mod_services/classes.serviceoptions.d.ts +2 -2
- package/dist_ts/plugins.d.ts +3 -1
- package/dist_ts/plugins.js +4 -2
- package/package.json +3 -2
- package/readme.md +54 -63
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.managedassets.ts +215 -0
- package/ts/helpers.ownerscopes.ts +3 -15
- package/ts/helpers.packagefiles.ts +6 -3
- package/ts/helpers.sealedrelease.ts +2 -2
- package/ts/helpers.tssea.ts +102 -0
- package/ts/helpers.workflow.ts +6 -28
- package/ts/index.ts +1 -1
- package/ts/mod_commit/mod.helpers.ts +33 -94
- package/ts/mod_commit/mod.ui.ts +0 -4
- package/ts/mod_config/index.ts +47 -35
- package/ts/mod_format/formatters/assets.formatter.ts +47 -108
- package/ts/mod_format/formatters/packagejson.formatter.ts +2 -2
- package/ts/mod_format/index.ts +36 -10
- package/ts/mod_format/interfaces.format.ts +0 -1
- package/ts/mod_release/helpers.releasepreparation.ts +36 -69
- package/ts/mod_release/index.ts +6 -16
- package/ts/mod_services/classes.serviceconfiguration.ts +2 -2
- package/ts/mod_services/classes.serviceoptions.ts +2 -2
- package/ts/plugins.ts +4 -0
- package/assets/templates/asset_deno_binary_release_gitea/.gitea/workflows/release.yml +0 -154
- package/assets/templates/multienv/deno.json +0 -8
- package/dist_ts/mod_format/formatters/deno.formatter.d.ts +0 -18
- package/dist_ts/mod_format/formatters/deno.formatter.js +0 -175
- package/ts/mod_format/formatters/deno.formatter.ts +0 -219
|
@@ -6,6 +6,12 @@ import { ScafTemplate } from '../../mod_template/classes.scaftemplate.js';
|
|
|
6
6
|
import { logger, logVerbose } from '../../gitzone.logging.js';
|
|
7
7
|
import { getCliConfigValue, readSmartconfigFile } from '../../helpers.smartconfig.js';
|
|
8
8
|
import { getSealedReleaseConfigError } from '../../helpers.sealedrelease.js';
|
|
9
|
+
import {
|
|
10
|
+
assertManagedAssetsCurrent,
|
|
11
|
+
managedAssetKinds,
|
|
12
|
+
readBinaryBuild,
|
|
13
|
+
type IBinaryBuild,
|
|
14
|
+
} from '../../helpers.managedassets.js';
|
|
9
15
|
|
|
10
16
|
interface IAssetFileMapping {
|
|
11
17
|
from: string;
|
|
@@ -20,16 +26,6 @@ interface IAssetTemplateEntry {
|
|
|
20
26
|
variables?: Record<string, any>;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
interface IBinaryTargetRenderData {
|
|
24
|
-
name: string;
|
|
25
|
-
assetName: string;
|
|
26
|
-
os: string;
|
|
27
|
-
arch: string;
|
|
28
|
-
denoTarget: string;
|
|
29
|
-
nodeKey: string;
|
|
30
|
-
label: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
29
|
const isPlainObject = (value: unknown): value is Record<string, any> => {
|
|
34
30
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
35
31
|
};
|
|
@@ -62,7 +58,7 @@ const normalizeRepository = (assetsConfig: Record<string, any>, moduleConfig: Re
|
|
|
62
58
|
const repository = isPlainObject(assetsConfig.repository) ? assetsConfig.repository : {};
|
|
63
59
|
const host = repository.host || moduleConfig.githost || 'code.foss.global';
|
|
64
60
|
const path = repository.path || [moduleConfig.gitscope, moduleConfig.gitrepo].filter(Boolean).join('/');
|
|
65
|
-
const branch = repository.branch ||
|
|
61
|
+
const branch = repository.branch || 'main';
|
|
66
62
|
const baseUrl = `https://${host}/${path}`;
|
|
67
63
|
return {
|
|
68
64
|
host,
|
|
@@ -74,64 +70,6 @@ const normalizeRepository = (assetsConfig: Record<string, any>, moduleConfig: Re
|
|
|
74
70
|
};
|
|
75
71
|
};
|
|
76
72
|
|
|
77
|
-
const normalizeOs = (target: Record<string, any>): string => {
|
|
78
|
-
const rawValue = `${target.os || ''} ${target.target || ''} ${target.name || ''}`.toLowerCase();
|
|
79
|
-
if (rawValue.includes('apple') || rawValue.includes('darwin') || rawValue.includes('macos')) return 'macos';
|
|
80
|
-
if (rawValue.includes('windows') || rawValue.includes('pc-windows') || rawValue.includes('-win')) return 'windows';
|
|
81
|
-
return 'linux';
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const normalizeArch = (target: Record<string, any>): string => {
|
|
85
|
-
const rawValue = `${target.arch || ''} ${target.target || ''} ${target.name || ''}`.toLowerCase();
|
|
86
|
-
if (rawValue.includes('aarch64') || rawValue.includes('arm64')) return 'arm64';
|
|
87
|
-
return 'x64';
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const getNodePlatform = (os: string): string => {
|
|
91
|
-
if (os === 'macos') return 'darwin';
|
|
92
|
-
if (os === 'windows') return 'win32';
|
|
93
|
-
return 'linux';
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const getPlatformLabel = (target: IBinaryTargetRenderData): string => {
|
|
97
|
-
const osLabel = target.os === 'macos' ? 'macOS' : target.os === 'windows' ? 'Windows' : 'Linux';
|
|
98
|
-
const archLabel = target.arch === 'arm64' ? 'ARM64' : 'x64';
|
|
99
|
-
return `${osLabel} ${archLabel}`;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const normalizeBinaryTargets = (
|
|
103
|
-
assetsConfig: Record<string, any>,
|
|
104
|
-
smartconfigData: Record<string, any>,
|
|
105
|
-
): IBinaryTargetRenderData[] => {
|
|
106
|
-
const binaryConfig = isPlainObject(assetsConfig.binary) ? assetsConfig.binary : {};
|
|
107
|
-
const tsdenoConfig = smartconfigData['@git.zone/tsdeno'];
|
|
108
|
-
const targets = Array.isArray(binaryConfig.targets)
|
|
109
|
-
? binaryConfig.targets
|
|
110
|
-
: isPlainObject(tsdenoConfig) && Array.isArray(tsdenoConfig.compileTargets)
|
|
111
|
-
? tsdenoConfig.compileTargets
|
|
112
|
-
: [];
|
|
113
|
-
|
|
114
|
-
return targets
|
|
115
|
-
.filter((target) => isPlainObject(target) && typeof target.name === 'string')
|
|
116
|
-
.map((target) => {
|
|
117
|
-
const os = normalizeOs(target);
|
|
118
|
-
const arch = normalizeArch(target);
|
|
119
|
-
const isWindows = os === 'windows';
|
|
120
|
-
const assetName = isWindows && !target.name.endsWith('.exe') ? `${target.name}.exe` : target.name;
|
|
121
|
-
const result: IBinaryTargetRenderData = {
|
|
122
|
-
name: target.name,
|
|
123
|
-
assetName,
|
|
124
|
-
os,
|
|
125
|
-
arch,
|
|
126
|
-
denoTarget: target.target || target.denoTarget || '',
|
|
127
|
-
nodeKey: `${getNodePlatform(os)}:${arch}`,
|
|
128
|
-
label: '',
|
|
129
|
-
};
|
|
130
|
-
result.label = getPlatformLabel(result);
|
|
131
|
-
return result;
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
|
|
135
73
|
const buildDefaultEntries = (assetsConfig: Record<string, any>, cliName: string): IAssetTemplateEntry[] => {
|
|
136
74
|
if (assetsConfig.kind === 'tspackRelease') {
|
|
137
75
|
return [{
|
|
@@ -144,29 +82,25 @@ const buildDefaultEntries = (assetsConfig: Record<string, any>, cliName: string)
|
|
|
144
82
|
],
|
|
145
83
|
}];
|
|
146
84
|
}
|
|
147
|
-
if (assetsConfig.kind !== '
|
|
85
|
+
if (assetsConfig.kind !== 'binaryCli') {
|
|
148
86
|
return [];
|
|
149
87
|
}
|
|
150
88
|
|
|
151
89
|
const entries: IAssetTemplateEntry[] = [];
|
|
152
90
|
const installerConfig = isPlainObject(assetsConfig.installer) ? assetsConfig.installer : {};
|
|
153
91
|
const npmWrapperConfig = isPlainObject(assetsConfig.npmWrapper) ? assetsConfig.npmWrapper : {};
|
|
154
|
-
const releaseWorkflowConfig = isPlainObject(assetsConfig.releaseWorkflow)
|
|
155
|
-
? assetsConfig.releaseWorkflow
|
|
156
|
-
: isPlainObject(assetsConfig.releaseAssets)
|
|
157
|
-
? assetsConfig.releaseAssets
|
|
158
|
-
: {};
|
|
92
|
+
const releaseWorkflowConfig = isPlainObject(assetsConfig.releaseWorkflow) ? assetsConfig.releaseWorkflow : {};
|
|
159
93
|
|
|
160
94
|
if (installerConfig.enabled !== false) {
|
|
161
95
|
entries.push({
|
|
162
|
-
template: '
|
|
96
|
+
template: 'asset_binary_installer',
|
|
163
97
|
files: [{ from: 'install.sh', to: installerConfig.file || 'install.sh', mode: '0755' }],
|
|
164
98
|
});
|
|
165
99
|
}
|
|
166
100
|
|
|
167
101
|
if (npmWrapperConfig.enabled === true) {
|
|
168
102
|
entries.push({
|
|
169
|
-
template: '
|
|
103
|
+
template: 'asset_binary_postinstall',
|
|
170
104
|
files: [
|
|
171
105
|
{
|
|
172
106
|
from: 'scripts/install-binary.js',
|
|
@@ -184,7 +118,7 @@ const buildDefaultEntries = (assetsConfig: Record<string, any>, cliName: string)
|
|
|
184
118
|
|
|
185
119
|
if (releaseWorkflowConfig.enabled !== false) {
|
|
186
120
|
entries.push({
|
|
187
|
-
template: '
|
|
121
|
+
template: 'asset_binary_release_gitea',
|
|
188
122
|
files: [{ from: '.gitea/workflows/release.yml', to: releaseWorkflowConfig.file || '.gitea/workflows/release.yml' }],
|
|
189
123
|
});
|
|
190
124
|
}
|
|
@@ -203,9 +137,9 @@ export class AssetsFormatter extends BaseFormatter {
|
|
|
203
137
|
logVerbose('No @git.zone/cli.assets config found, skipping');
|
|
204
138
|
return [];
|
|
205
139
|
}
|
|
140
|
+
assertManagedAssetsCurrent(assetsConfig);
|
|
206
141
|
|
|
207
|
-
const
|
|
208
|
-
const renderData = await this.buildRenderData(assetsConfig, smartconfigData);
|
|
142
|
+
const renderData = await this.buildRenderData(assetsConfig);
|
|
209
143
|
const entries = this.getTemplateEntries(assetsConfig, renderData.cliName);
|
|
210
144
|
const changes: IPlannedChange[] = [];
|
|
211
145
|
|
|
@@ -258,8 +192,14 @@ export class AssetsFormatter extends BaseFormatter {
|
|
|
258
192
|
const error = getSealedReleaseConfigError(assetsConfig.sealedRelease);
|
|
259
193
|
return error ? [{ level: 'error', module: this.name, message: error }] : [];
|
|
260
194
|
}
|
|
261
|
-
if (assetsConfig.kind && assetsConfig.kind
|
|
262
|
-
return [
|
|
195
|
+
if (assetsConfig.kind !== undefined && !(managedAssetKinds as readonly unknown[]).includes(assetsConfig.kind)) {
|
|
196
|
+
return [
|
|
197
|
+
{
|
|
198
|
+
level: 'error',
|
|
199
|
+
module: this.name,
|
|
200
|
+
message: `Unsupported managed asset kind: ${assetsConfig.kind}. Use ${managedAssetKinds.join(' or ')}.`,
|
|
201
|
+
},
|
|
202
|
+
];
|
|
263
203
|
}
|
|
264
204
|
const installer = isPlainObject(assetsConfig.installer) ? assetsConfig.installer : {};
|
|
265
205
|
if (installer.distribution && !['rawBranch', 'releaseAsset'].includes(installer.distribution)) {
|
|
@@ -323,38 +263,37 @@ export class AssetsFormatter extends BaseFormatter {
|
|
|
323
263
|
return fileMap;
|
|
324
264
|
}
|
|
325
265
|
|
|
326
|
-
private async buildRenderData(
|
|
327
|
-
assetsConfig: Record<string, any>,
|
|
328
|
-
smartconfigData: Record<string, any>,
|
|
329
|
-
): Promise<Record<string, any>> {
|
|
266
|
+
private async buildRenderData(assetsConfig: Record<string, any>): Promise<Record<string, any>> {
|
|
330
267
|
const packageJson = await readJsonFile(plugins.path.join(paths.cwd, 'package.json'));
|
|
331
|
-
const denoJson = await readJsonFile(plugins.path.join(paths.cwd, 'deno.json'));
|
|
332
268
|
const moduleConfig = this.project.gitzoneConfig?.data?.module || {};
|
|
333
269
|
const cliName = assetsConfig.cliName || packageJson.name?.split('/').pop() || moduleConfig.gitrepo || 'app';
|
|
334
270
|
const displayName = assetsConfig.displayName || cliName.toUpperCase();
|
|
335
271
|
const repository = normalizeRepository(assetsConfig, moduleConfig);
|
|
336
272
|
const npmPackageName = (moduleConfig as any).npmPackagename || moduleConfig.npmPackageName;
|
|
337
|
-
const
|
|
273
|
+
const binaryBuild =
|
|
274
|
+
assetsConfig.kind === 'binaryCli'
|
|
275
|
+
? await readBinaryBuild(paths.cwd, await readSmartconfigFile(paths.cwd))
|
|
276
|
+
: { outDir: '', targets: [] };
|
|
277
|
+
const binaryTargets = binaryBuild.targets;
|
|
338
278
|
const binaryConfig = isPlainObject(assetsConfig.binary) ? assetsConfig.binary : {};
|
|
339
279
|
const installerConfig = this.normalizeInstallerConfig(assetsConfig, cliName, repository);
|
|
340
280
|
const npmWrapperConfig = this.normalizeNpmWrapperConfig(assetsConfig, cliName);
|
|
341
|
-
const releaseWorkflowConfig = this.normalizeReleaseWorkflowConfig(assetsConfig,
|
|
281
|
+
const releaseWorkflowConfig = this.normalizeReleaseWorkflowConfig(assetsConfig, binaryBuild, installerConfig);
|
|
342
282
|
|
|
343
283
|
return {
|
|
344
284
|
module: moduleConfig,
|
|
345
285
|
projectType: this.project.gitzoneConfig?.data?.projectType,
|
|
346
286
|
packageJson,
|
|
347
|
-
denoJson,
|
|
348
287
|
assets: assetsConfig,
|
|
349
288
|
cliName,
|
|
350
289
|
cliNameUpper: cliName.toUpperCase(),
|
|
351
290
|
displayName,
|
|
352
291
|
packageName: assetsConfig.packageName || packageJson.name || npmPackageName || cliName,
|
|
353
|
-
versionFallback: packageJson.version ||
|
|
292
|
+
versionFallback: packageJson.version || '0.0.0',
|
|
354
293
|
repository,
|
|
355
294
|
binary: {
|
|
356
295
|
...binaryConfig,
|
|
357
|
-
outDir:
|
|
296
|
+
outDir: binaryBuild.outDir,
|
|
358
297
|
installFileName: binaryConfig.installFileName || cliName,
|
|
359
298
|
targets: binaryTargets,
|
|
360
299
|
supportedPlatformText: binaryTargets.map((target) => target.label).join(', '),
|
|
@@ -373,14 +312,14 @@ export class AssetsFormatter extends BaseFormatter {
|
|
|
373
312
|
): Record<string, any> {
|
|
374
313
|
const installer = isPlainObject(assetsConfig.installer) ? assetsConfig.installer : {};
|
|
375
314
|
const modes = isPlainObject(installer.modes) ? installer.modes : {};
|
|
376
|
-
const source = isPlainObject(modes.source) ? modes.source :
|
|
315
|
+
const source = isPlainObject(modes.source) ? modes.source : {};
|
|
377
316
|
const service = isPlainObject(installer.service) ? installer.service : {};
|
|
378
317
|
const file = installer.file || 'install.sh';
|
|
379
318
|
const releaseAssetName = plugins.path.basename(file);
|
|
380
|
-
const distribution = installer.distribution ||
|
|
319
|
+
const distribution = installer.distribution || 'rawBranch';
|
|
381
320
|
const versionSelection = uniqueStringArray(installer.versionSelection, ['latest', 'version']);
|
|
382
321
|
const detectNames = uniqueStringArray(service.detectNames, service.name ? [service.name] : [cliName]);
|
|
383
|
-
const removeLegacyUnits = uniqueStringArray(service.removeLegacyUnits ||
|
|
322
|
+
const removeLegacyUnits = uniqueStringArray(service.removeLegacyUnits || []);
|
|
384
323
|
const ensureDirs = uniqueStringArray(installer.ensureDirs);
|
|
385
324
|
const preservePaths = uniqueStringArray(installer.preservePaths);
|
|
386
325
|
const successHints = uniqueStringArray(installer.successHints, [`${cliName} --version`, `${cliName} --help`]);
|
|
@@ -398,7 +337,7 @@ export class AssetsFormatter extends BaseFormatter {
|
|
|
398
337
|
releaseNotesInstallUrl: distribution === 'releaseAsset' ? releaseNotesInstallUrl : rawBranchInstallUrl,
|
|
399
338
|
installDir: installer.installDir || `/opt/${cliName}`,
|
|
400
339
|
binDir: installer.binDir || '/usr/local/bin',
|
|
401
|
-
defaultMode: modes.default ||
|
|
340
|
+
defaultMode: modes.default || 'binary',
|
|
402
341
|
versionSelection,
|
|
403
342
|
supportsMajor: versionSelection.includes('major'),
|
|
404
343
|
source: {
|
|
@@ -407,7 +346,7 @@ export class AssetsFormatter extends BaseFormatter {
|
|
|
407
346
|
commands: uniqueStringArray(source.commands),
|
|
408
347
|
executable: source.executable || 'cli.js',
|
|
409
348
|
executableFiles: uniqueStringArray(source.executableFiles, source.executable ? [source.executable] : ['cli.js']),
|
|
410
|
-
validateCommand: source.validate ||
|
|
349
|
+
validateCommand: source.validate || `node ${source.executable || 'cli.js'} --version`,
|
|
411
350
|
},
|
|
412
351
|
service: {
|
|
413
352
|
...service,
|
|
@@ -438,31 +377,31 @@ export class AssetsFormatter extends BaseFormatter {
|
|
|
438
377
|
|
|
439
378
|
private normalizeReleaseWorkflowConfig(
|
|
440
379
|
assetsConfig: Record<string, any>,
|
|
441
|
-
|
|
380
|
+
binaryBuild: IBinaryBuild,
|
|
442
381
|
installerConfig: Record<string, any>,
|
|
443
382
|
): Record<string, any> {
|
|
444
|
-
const releaseWorkflow = isPlainObject(assetsConfig.releaseWorkflow)
|
|
445
|
-
? assetsConfig.releaseWorkflow
|
|
446
|
-
: isPlainObject(assetsConfig.releaseAssets)
|
|
447
|
-
? assetsConfig.releaseAssets
|
|
448
|
-
: {};
|
|
449
|
-
const binaryOutDir = binaryConfig.outDir || 'dist/binaries';
|
|
450
|
-
const assetGlobs = uniqueStringArray(releaseWorkflow.assetGlobs || releaseWorkflow.include, [`${binaryOutDir}/*`]);
|
|
383
|
+
const releaseWorkflow = isPlainObject(assetsConfig.releaseWorkflow) ? assetsConfig.releaseWorkflow : {};
|
|
451
384
|
const includeInstallerAsset =
|
|
452
385
|
typeof releaseWorkflow.includeInstallerAsset === 'boolean'
|
|
453
386
|
? releaseWorkflow.includeInstallerAsset
|
|
454
387
|
: installerConfig.enabled !== false && installerConfig.distribution === 'releaseAsset';
|
|
388
|
+
// Exactly the files this release built: the output directory can still hold
|
|
389
|
+
// executables of removed targets or an interrupted build's work directory.
|
|
390
|
+
const releaseFileNames = binaryBuild.targets.flatMap((target) => [target.name, ...target.noticeFiles]);
|
|
391
|
+
if (includeInstallerAsset) {
|
|
392
|
+
releaseFileNames.push(installerConfig.releaseAssetName);
|
|
393
|
+
}
|
|
455
394
|
return {
|
|
456
395
|
...releaseWorkflow,
|
|
457
396
|
enabled: releaseWorkflow.enabled !== false,
|
|
458
397
|
file: releaseWorkflow.file || '.gitea/workflows/release.yml',
|
|
459
398
|
installCommand: releaseWorkflow.installCommand || 'pnpm install --ignore-scripts',
|
|
460
|
-
compileCommand: releaseWorkflow.compileCommand || 'pnpm exec
|
|
399
|
+
compileCommand: releaseWorkflow.compileCommand || 'pnpm exec tsbundle && pnpm exec tssea build',
|
|
461
400
|
packNpmArtifact: releaseWorkflow.packNpmArtifact === true,
|
|
462
401
|
includeInstallerAsset,
|
|
463
|
-
|
|
402
|
+
releaseFileNames,
|
|
464
403
|
keepReleases: releaseWorkflow.keepReleases ?? 0,
|
|
465
|
-
binaryOutDir,
|
|
404
|
+
binaryOutDir: binaryBuild.outDir,
|
|
466
405
|
};
|
|
467
406
|
}
|
|
468
407
|
}
|
|
@@ -73,13 +73,13 @@ export class PackageJsonFormatter extends BaseFormatter {
|
|
|
73
73
|
|
|
74
74
|
const rawAssetsConfig = gitzoneData.assets;
|
|
75
75
|
const assetsConfig = rawAssetsConfig?.enabled === false ? undefined : rawAssetsConfig;
|
|
76
|
-
const managedAssetConfig = rawAssetsConfig?.kind === '
|
|
76
|
+
const managedAssetConfig = rawAssetsConfig?.kind === 'binaryCli' ? rawAssetsConfig : undefined;
|
|
77
77
|
const managedCliName = managedAssetConfig?.cliName || packageJson.name?.split('/').pop();
|
|
78
78
|
const managedBinFile = managedAssetConfig?.npmWrapper?.binFile || `bin/${managedCliName}-wrapper.js`;
|
|
79
79
|
const managedPostinstallFile = managedAssetConfig?.npmWrapper?.postinstallFile || 'scripts/install-binary.js';
|
|
80
80
|
const managedPostinstallCommand = `node ${managedPostinstallFile}`;
|
|
81
81
|
|
|
82
|
-
if (assetsConfig?.kind === '
|
|
82
|
+
if (assetsConfig?.kind === 'binaryCli' && assetsConfig.npmWrapper?.enabled) {
|
|
83
83
|
if (managedCliName) {
|
|
84
84
|
packageJson.bin = typeof packageJson.bin === 'object' && !Array.isArray(packageJson.bin)
|
|
85
85
|
? packageJson.bin
|
package/ts/mod_format/index.ts
CHANGED
|
@@ -25,7 +25,6 @@ import { TemplatesFormatter } from "./formatters/templates.formatter.js";
|
|
|
25
25
|
import { AssetsFormatter } from "./formatters/assets.formatter.js";
|
|
26
26
|
import { GitignoreFormatter } from "./formatters/gitignore.formatter.js";
|
|
27
27
|
import { TsconfigFormatter } from "./formatters/tsconfig.formatter.js";
|
|
28
|
-
import { DenoFormatter } from "./formatters/deno.formatter.js";
|
|
29
28
|
import { PrettierFormatter } from "./formatters/prettier.formatter.js";
|
|
30
29
|
import { ReadmeFormatter } from "./formatters/readme.formatter.js";
|
|
31
30
|
import { CopyFormatter } from "./formatters/copy.formatter.js";
|
|
@@ -71,7 +70,6 @@ const formatterMap: Record<
|
|
|
71
70
|
assets: AssetsFormatter,
|
|
72
71
|
gitignore: GitignoreFormatter,
|
|
73
72
|
tsconfig: TsconfigFormatter,
|
|
74
|
-
deno: DenoFormatter,
|
|
75
73
|
prettier: PrettierFormatter,
|
|
76
74
|
readme: ReadmeFormatter,
|
|
77
75
|
copy: CopyFormatter,
|
|
@@ -83,9 +81,22 @@ const formattersNotRequiringProjectType = [
|
|
|
83
81
|
"prettier",
|
|
84
82
|
"cleanup",
|
|
85
83
|
"packagejson",
|
|
86
|
-
"deno",
|
|
87
84
|
];
|
|
88
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Refuses module names no formatter carries, so a misspelled or removed module
|
|
88
|
+
* never selects or skips nothing in silence.
|
|
89
|
+
*/
|
|
90
|
+
const assertKnownFormatModules = (namesArg: string[], sourceArg: string): void => {
|
|
91
|
+
const validNames = Object.keys(formatterMap);
|
|
92
|
+
const unknownNames = namesArg.filter((nameArg) => !validNames.includes(nameArg));
|
|
93
|
+
if (unknownNames.length > 0) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Unknown format module ${unknownNames.map((nameArg) => `"${nameArg}"`).join(", ")} in ${sourceArg}. Valid modules: ${validNames.join(", ")}.`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
89
100
|
const getFormatConfig = async () => {
|
|
90
101
|
const rawFormatConfig = await getCliConfigValue<Record<string, any>>(
|
|
91
102
|
"format",
|
|
@@ -148,13 +159,14 @@ const createActiveFormatters = async (options: {
|
|
|
148
159
|
([, FormatterClass]) => new FormatterClass(context, project),
|
|
149
160
|
);
|
|
150
161
|
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
const configOnly = normalizeModuleList(formatConfig.modules.only);
|
|
163
|
+
const configSkip = normalizeModuleList(formatConfig.modules.skip);
|
|
164
|
+
assertKnownFormatModules(options.only || [], "--only");
|
|
165
|
+
assertKnownFormatModules(options.skip || [], "--skip");
|
|
166
|
+
assertKnownFormatModules(configOnly, "@git.zone/cli.format.modules.only");
|
|
167
|
+
assertKnownFormatModules(configSkip, "@git.zone/cli.format.modules.skip");
|
|
168
|
+
const onlyModules = options.only?.length ? options.only : configOnly;
|
|
169
|
+
const skipModules = [...configSkip, ...(options.skip || [])];
|
|
158
170
|
|
|
159
171
|
const activeFormatters = formatters.filter((formatter) => {
|
|
160
172
|
if (onlyModules.length > 0) {
|
|
@@ -555,6 +567,20 @@ export let run = async (
|
|
|
555
567
|
return;
|
|
556
568
|
}
|
|
557
569
|
|
|
570
|
+
// A plan with errors is not applied in part: fix the errors, then write.
|
|
571
|
+
const writeStatus = getPlanStatus(plan);
|
|
572
|
+
if (writeStatus.hasErrors) {
|
|
573
|
+
for (const warning of plan.warnings.filter((warningArg) => warningArg.level === "error")) {
|
|
574
|
+
logger.log("error", `[${warning.module}] ${warning.message}`);
|
|
575
|
+
}
|
|
576
|
+
logger.log(
|
|
577
|
+
"error",
|
|
578
|
+
`Format write refused: the plan has ${writeStatus.errorCount} error warning(s). Nothing was written.`,
|
|
579
|
+
);
|
|
580
|
+
process.exitCode = 1;
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
|
|
558
584
|
// Interactive confirmation
|
|
559
585
|
if (interactive && !autoApprove) {
|
|
560
586
|
const proceed = await ask({
|
|
@@ -2,11 +2,6 @@ import * as plugins from "./mod.plugins.js";
|
|
|
2
2
|
import type { IResolvedReleaseWorkflow } from "../helpers.workflow.js";
|
|
3
3
|
import { logger } from "../gitzone.logging.js";
|
|
4
4
|
import { readPendingChangelog } from "../helpers.changelog.js";
|
|
5
|
-
import {
|
|
6
|
-
detectProjectType,
|
|
7
|
-
projectTypeHasPackageJson,
|
|
8
|
-
type ProjectType,
|
|
9
|
-
} from "../mod_commit/mod.helpers.js";
|
|
10
5
|
import { InterProcessLock } from "../mod_services/classes.interprocesslock.js";
|
|
11
6
|
import { ReleaseJournalStore } from "./classes.releasejournal.js";
|
|
12
7
|
import {
|
|
@@ -342,31 +337,12 @@ export const getReleaseCommandEnvironment = async (
|
|
|
342
337
|
};
|
|
343
338
|
|
|
344
339
|
/**
|
|
345
|
-
* The release checkout
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
|
|
351
|
-
export const detectReleaseCommitProjectType = async (
|
|
352
|
-
options: IReleaseSourceCommit,
|
|
353
|
-
): Promise<ProjectType> => {
|
|
354
|
-
const hasPackageJson = await commitCarriesBlob(options, "package.json");
|
|
355
|
-
const hasDenoJson = await commitCarriesBlob(options, "deno.json");
|
|
356
|
-
if (hasPackageJson && hasDenoJson) return "both";
|
|
357
|
-
if (hasPackageJson) return "npm";
|
|
358
|
-
if (hasDenoJson) return "deno";
|
|
359
|
-
throw new Error(
|
|
360
|
-
`Commit ${options.sourceOid} tracks neither package.json nor deno.json, so it carries no release version file.`,
|
|
361
|
-
);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* The isolated release checkout of a project with a package.json installs with
|
|
366
|
-
* `pnpm install --frozen-lockfile`, so a lockfile that the release commit does
|
|
367
|
-
* not carry, or that no longer matches its manifest, would fail a release that
|
|
368
|
-
* already created its commit and tag. Preflight proves both before anything is
|
|
369
|
-
* created. A Deno-only commit installs nothing, so it is asked for nothing.
|
|
340
|
+
* The isolated release checkout installs with `pnpm install --frozen-lockfile`,
|
|
341
|
+
* so a package.json or lockfile that the release commit does not carry, or a
|
|
342
|
+
* lockfile that no longer matches its manifest, would fail a release that
|
|
343
|
+
* already created its commit and tag. Preflight proves all three before
|
|
344
|
+
* anything is created. The release commit is what counts, not the working
|
|
345
|
+
* folder: an ignored package.json is not part of the release.
|
|
370
346
|
*
|
|
371
347
|
* The release commit only adds the version bump, the baked commit info, and the
|
|
372
348
|
* changelog section on top of the source commit, and a version change never
|
|
@@ -375,13 +351,10 @@ export const detectReleaseCommitProjectType = async (
|
|
|
375
351
|
export const assertReleaseCheckoutInstallable = async (
|
|
376
352
|
options: IReleaseSourceCommit,
|
|
377
353
|
): Promise<void> => {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
"info",
|
|
382
|
-
"The release commit carries no package.json, so its checkout runs the configured commands against the committed tree without installing npm dependencies",
|
|
354
|
+
if (!(await commitCarriesBlob(options, "package.json"))) {
|
|
355
|
+
throw new Error(
|
|
356
|
+
`Commit ${options.sourceOid} tracks no package.json: gitzone commit and release version the package.json.`,
|
|
383
357
|
);
|
|
384
|
-
return;
|
|
385
358
|
}
|
|
386
359
|
logger.log(
|
|
387
360
|
"info",
|
|
@@ -498,40 +471,34 @@ export const withIsolatedReleaseCheckout = async <T>(
|
|
|
498
471
|
cwd: checkout,
|
|
499
472
|
sourceOid: options.mainOid,
|
|
500
473
|
});
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
474
|
+
const install = await options.smartshell.execSpawn(
|
|
475
|
+
"pnpm",
|
|
476
|
+
[
|
|
477
|
+
"install",
|
|
478
|
+
"--frozen-lockfile",
|
|
479
|
+
...(env.PNPM_CONFIG_IGNORE_WORKSPACE === "true"
|
|
480
|
+
? ["--ignore-workspace"]
|
|
481
|
+
: []),
|
|
482
|
+
],
|
|
483
|
+
{
|
|
484
|
+
cwd: checkout,
|
|
485
|
+
env,
|
|
486
|
+
timeout: 10 * 60_000,
|
|
487
|
+
timeoutKillGraceMs: 5_000,
|
|
488
|
+
},
|
|
489
|
+
);
|
|
490
|
+
if (install.exitCode !== 0)
|
|
491
|
+
throw new Error(
|
|
492
|
+
formatCommandFailure(
|
|
493
|
+
"Release checkout dependency installation failed.",
|
|
494
|
+
install,
|
|
495
|
+
{
|
|
496
|
+
command: "pnpm install --frozen-lockfile",
|
|
497
|
+
timeoutMs: 10 * 60_000,
|
|
498
|
+
output: "combined",
|
|
499
|
+
},
|
|
500
|
+
),
|
|
521
501
|
);
|
|
522
|
-
if (install.exitCode !== 0)
|
|
523
|
-
throw new Error(
|
|
524
|
-
formatCommandFailure(
|
|
525
|
-
"Release checkout dependency installation failed.",
|
|
526
|
-
install,
|
|
527
|
-
{
|
|
528
|
-
command: "pnpm install --frozen-lockfile",
|
|
529
|
-
timeoutMs: 10 * 60_000,
|
|
530
|
-
output: "combined",
|
|
531
|
-
},
|
|
532
|
-
),
|
|
533
|
-
);
|
|
534
|
-
}
|
|
535
502
|
if (options.testCommand)
|
|
536
503
|
await run(
|
|
537
504
|
options.smartshell,
|
package/ts/mod_release/index.ts
CHANGED
|
@@ -245,7 +245,6 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
245
245
|
);
|
|
246
246
|
const versionResolution = resolveReleaseVersion({
|
|
247
247
|
currentVersion: await commitHelpers.readCurrentVersion(
|
|
248
|
-
workflow.projectType,
|
|
249
248
|
branchContext.sourceCwd,
|
|
250
249
|
),
|
|
251
250
|
pendingChangelog: pending.block,
|
|
@@ -335,10 +334,9 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
335
334
|
),
|
|
336
335
|
);
|
|
337
336
|
}
|
|
338
|
-
// A release that builds or packs does so in a checkout of its release commit
|
|
339
|
-
//
|
|
340
|
-
//
|
|
341
|
-
// created yet.
|
|
337
|
+
// A release that builds or packs does so in a checkout of its release commit,
|
|
338
|
+
// which installs from the committed lockfile: prove that install can succeed
|
|
339
|
+
// while nothing has been created yet.
|
|
342
340
|
if (releaseNeedsIsolatedCheckout(workflow)) {
|
|
343
341
|
await assertReleaseCheckoutInstallable({
|
|
344
342
|
smartshell: smartshellInstance,
|
|
@@ -392,7 +390,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
|
|
|
392
390
|
expectedRemoteMainOid = integration.expectedRemoteMainOid;
|
|
393
391
|
}
|
|
394
392
|
|
|
395
|
-
await runVersionStep(
|
|
393
|
+
await runVersionStep(versionResolution, releaseCwd);
|
|
396
394
|
await runChangelogStep(workflow, newVersion, releaseCwd);
|
|
397
395
|
const releaseCommitOid = await runReleaseCommitStep(
|
|
398
396
|
smartshellInstance,
|
|
@@ -2254,14 +2252,10 @@ async function verifyCleanTree(
|
|
|
2254
2252
|
}
|
|
2255
2253
|
|
|
2256
2254
|
async function runVersionStep(
|
|
2257
|
-
projectType: commitHelpers.ProjectType,
|
|
2258
2255
|
resolutionArg: IReleaseVersionResolution,
|
|
2259
2256
|
cwdArg: string,
|
|
2260
2257
|
): Promise<void> {
|
|
2261
|
-
const currentVersion = await commitHelpers.readCurrentVersion(
|
|
2262
|
-
projectType,
|
|
2263
|
-
cwdArg,
|
|
2264
|
-
);
|
|
2258
|
+
const currentVersion = await commitHelpers.readCurrentVersion(cwdArg);
|
|
2265
2259
|
assertResolvedCurrentVersion(resolutionArg, currentVersion);
|
|
2266
2260
|
logger.log(
|
|
2267
2261
|
"info",
|
|
@@ -2269,11 +2263,7 @@ async function runVersionStep(
|
|
|
2269
2263
|
);
|
|
2270
2264
|
|
|
2271
2265
|
await writeCommitInfoFiles(cwdArg, resolutionArg.version);
|
|
2272
|
-
await commitHelpers.updateProjectVersionFiles(
|
|
2273
|
-
projectType,
|
|
2274
|
-
resolutionArg.version,
|
|
2275
|
-
cwdArg,
|
|
2276
|
-
);
|
|
2266
|
+
await commitHelpers.updateProjectVersionFiles(resolutionArg.version, cwdArg);
|
|
2277
2267
|
}
|
|
2278
2268
|
|
|
2279
2269
|
async function runChangelogStep(
|
|
@@ -149,8 +149,8 @@ export interface IServiceConfig extends IServicePlatformEnvironment {
|
|
|
149
149
|
MONGODB_URL: string;
|
|
150
150
|
/**
|
|
151
151
|
* When false, the NoSQLDB engine runs without authentication. It is always
|
|
152
|
-
* published on loopback only. Opt-in, for
|
|
153
|
-
*
|
|
152
|
+
* published on loopback only. Opt-in, for clients that cannot complete a SCRAM
|
|
153
|
+
* handshake. Defaults to true.
|
|
154
154
|
*/
|
|
155
155
|
MONGODB_AUTH_ENABLED: boolean;
|
|
156
156
|
/**
|
|
@@ -24,8 +24,8 @@ export const serviceOptionsConfigKey = 'serviceOptions';
|
|
|
24
24
|
export interface IMongodbServiceOptions {
|
|
25
25
|
/**
|
|
26
26
|
* When false, mongod runs without authentication and is published on
|
|
27
|
-
* loopback only. Opt-in, for
|
|
28
|
-
*
|
|
27
|
+
* loopback only. Opt-in, for clients that cannot complete a SCRAM handshake.
|
|
28
|
+
* Absent means enabled.
|
|
29
29
|
*/
|
|
30
30
|
auth?: boolean;
|
|
31
31
|
}
|
package/ts/plugins.ts
CHANGED
|
@@ -9,6 +9,8 @@ import * as crypto from 'node:crypto';
|
|
|
9
9
|
import * as fsSync from 'node:fs';
|
|
10
10
|
import * as childProcess from 'node:child_process';
|
|
11
11
|
import * as tty from 'node:tty';
|
|
12
|
+
import * as nodeModule from 'node:module';
|
|
13
|
+
import * as nodeUrl from 'node:url';
|
|
12
14
|
import * as projectinfo from '@push.rocks/projectinfo';
|
|
13
15
|
import * as smartconsole from '@push.rocks/smartconsole';
|
|
14
16
|
import * as smartpath from '@push.rocks/smartpath';
|
|
@@ -62,6 +64,8 @@ export {
|
|
|
62
64
|
fsSync,
|
|
63
65
|
childProcess,
|
|
64
66
|
tty,
|
|
67
|
+
nodeModule,
|
|
68
|
+
nodeUrl,
|
|
65
69
|
projectinfo,
|
|
66
70
|
smartconsole,
|
|
67
71
|
smartpath,
|