@git.zone/cli 8.11.0 → 9.0.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/assets/templates/{asset_deno_binary_installer → asset_binary_installer}/install.sh +134 -40
- package/assets/templates/{asset_deno_binary_postinstall → asset_binary_postinstall}/bin/wrapper.js +13 -4
- package/assets/templates/asset_binary_postinstall/scripts/install-binary.js +211 -0
- package/assets/templates/asset_binary_release_gitea/.gitea/workflows/release.yml +194 -0
- package/assets/templates/asset_binary_release_gitea/scripts/gitzone-binary-release.d.mts +29 -0
- package/assets/templates/asset_binary_release_gitea/scripts/gitzone-binary-release.mjs +168 -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 +57 -93
- 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 +69 -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 +62 -109
- 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_postinstall/scripts/install-binary.js +0 -123
- 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
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { ITsseaOutputs, resolveOutputs } from '@git.zone/tssea/config';
|
|
2
|
+
import * as plugins from './plugins.js';
|
|
3
|
+
import { isPlainObject } from './helpers.objects.js';
|
|
4
|
+
|
|
5
|
+
export type { ITsseaOutput, ITsseaOutputs } from '@git.zone/tssea/config';
|
|
6
|
+
|
|
7
|
+
/** The tssea package whose `./config` export resolves a project's executables. */
|
|
8
|
+
export const tsseaPackageName = '@git.zone/tssea';
|
|
9
|
+
|
|
10
|
+
/** The `@git.zone/tssea` versions whose `./config` export this CLI reads: `^1.1.0`. */
|
|
11
|
+
export const supportedTsseaRange = '^1.1.0';
|
|
12
|
+
|
|
13
|
+
/** The `./config` module of the project's tssea; loaded at run time from the project, typed from the CLI's devDependency. */
|
|
14
|
+
interface ITsseaConfigModule {
|
|
15
|
+
resolveOutputs: typeof resolveOutputs;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** A tssea failure, recognized by shape: `instanceof` fails across package copies. */
|
|
19
|
+
const isTsseaError = (errorArg: unknown): errorArg is Error & { code: string } =>
|
|
20
|
+
errorArg instanceof Error &&
|
|
21
|
+
errorArg.name === 'TsseaError' &&
|
|
22
|
+
typeof (errorArg as Error & { code?: unknown }).code === 'string';
|
|
23
|
+
|
|
24
|
+
/** Whether an exact `x.y.z` version satisfies `^1.1.0`; prereleases do not. */
|
|
25
|
+
const isSupportedTsseaVersion = (versionArg: string): boolean => {
|
|
26
|
+
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(versionArg);
|
|
27
|
+
if (!match) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const [major, minor] = [Number(match[1]), Number(match[2])];
|
|
31
|
+
return major === 1 && minor >= 1;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const readProjectManifest = async (projectDirArg: string): Promise<Record<string, unknown>> => {
|
|
35
|
+
const manifestPath = plugins.path.join(projectDirArg, 'package.json');
|
|
36
|
+
let content: string;
|
|
37
|
+
try {
|
|
38
|
+
content = await plugins.fs.readFile(manifestPath, 'utf8');
|
|
39
|
+
} catch (error) {
|
|
40
|
+
throw new Error(`binaryCli assets need the project's package.json: ${manifestPath} cannot be read.`, {
|
|
41
|
+
cause: error,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const manifest: unknown = JSON.parse(content);
|
|
45
|
+
if (!isPlainObject(manifest)) {
|
|
46
|
+
throw new Error(`${manifestPath} does not hold a JSON object.`);
|
|
47
|
+
}
|
|
48
|
+
return manifest;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const declaresDependency = (manifestArg: Record<string, unknown>, nameArg: string): boolean =>
|
|
52
|
+
['dependencies', 'devDependencies'].some((fieldArg) => {
|
|
53
|
+
const field = manifestArg[fieldArg];
|
|
54
|
+
return isPlainObject(field) && typeof field[nameArg] === 'string';
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Resolves the executables of the project's `@git.zone/tssea` configuration with the tssea
|
|
59
|
+
* the project itself installs, so the project's tssea version interprets its own config.
|
|
60
|
+
*/
|
|
61
|
+
export const resolveProjectTsseaOutputs = async (
|
|
62
|
+
projectDirArg: string,
|
|
63
|
+
smartconfigDataArg: Record<string, unknown>,
|
|
64
|
+
): Promise<ITsseaOutputs> => {
|
|
65
|
+
const manifest = await readProjectManifest(projectDirArg);
|
|
66
|
+
if (!declaresDependency(manifest, tsseaPackageName)) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`binaryCli builds with ${tsseaPackageName}; \`pnpm install --save-dev ${tsseaPackageName}\`, then rerun.`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
// The project's own direct link, never one an ancestor folder would resolve.
|
|
72
|
+
const installPath = plugins.path.join(projectDirArg, 'node_modules', ...tsseaPackageName.split('/'));
|
|
73
|
+
try {
|
|
74
|
+
await plugins.fs.lstat(installPath);
|
|
75
|
+
} catch {
|
|
76
|
+
throw new Error(`${tsseaPackageName} is declared but not installed in ${projectDirArg}: run \`pnpm install\`, then rerun.`);
|
|
77
|
+
}
|
|
78
|
+
const projectRequire = plugins.nodeModule.createRequire(plugins.path.join(projectDirArg, 'package.json'));
|
|
79
|
+
const installedManifest: unknown = projectRequire(`${tsseaPackageName}/package.json`);
|
|
80
|
+
const installedVersion =
|
|
81
|
+
isPlainObject(installedManifest) && typeof installedManifest.version === 'string'
|
|
82
|
+
? installedManifest.version
|
|
83
|
+
: 'unknown';
|
|
84
|
+
if (!isSupportedTsseaVersion(installedVersion)) {
|
|
85
|
+
const newerMajor = /^(\d+)\./.exec(installedVersion);
|
|
86
|
+
throw new Error(
|
|
87
|
+
newerMajor && Number(newerMajor[1]) > 1
|
|
88
|
+
? `The project installs ${tsseaPackageName} ${installedVersion}, but this @git.zone/cli supports ${supportedTsseaRange}: update @git.zone/cli.`
|
|
89
|
+
: `The project installs ${tsseaPackageName} ${installedVersion}, but this @git.zone/cli supports ${supportedTsseaRange}: upgrade ${tsseaPackageName} in the project.`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
const configModuleUrl = plugins.nodeUrl.pathToFileURL(projectRequire.resolve(`${tsseaPackageName}/config`)).href;
|
|
93
|
+
const configModule = (await import(configModuleUrl)) as ITsseaConfigModule;
|
|
94
|
+
try {
|
|
95
|
+
return configModule.resolveOutputs(smartconfigDataArg[tsseaPackageName], projectDirArg);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (isTsseaError(error)) {
|
|
98
|
+
throw new Error(`${tsseaPackageName}: ${error.message} [${error.code}]`, { cause: error });
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
};
|
package/ts/helpers.workflow.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { getCliConfigValue } from "./helpers.smartconfig.js";
|
|
2
2
|
import { shouldCleanTestArtifactsOnRelease } from "./helpers.tstest.js";
|
|
3
|
-
import {
|
|
4
|
-
detectProjectType,
|
|
5
|
-
projectTypeHasPackageJson,
|
|
6
|
-
type ProjectType,
|
|
7
|
-
} from "./mod_commit/mod.helpers.js";
|
|
8
3
|
import {
|
|
9
4
|
parseReleaseVersionFloor,
|
|
10
5
|
parseReleasePrerelease,
|
|
@@ -321,8 +316,6 @@ export interface IResolvedReleaseWorkflow {
|
|
|
321
316
|
confirmation: TConfirmationMode;
|
|
322
317
|
recordRetention: number;
|
|
323
318
|
plan: string[];
|
|
324
|
-
/** Version files and dependency installation the project owns. */
|
|
325
|
-
projectType: ProjectType;
|
|
326
319
|
targets: TReleaseTarget[];
|
|
327
320
|
runTests: boolean;
|
|
328
321
|
runBuild: boolean;
|
|
@@ -809,7 +802,6 @@ const buildReleasePlan = (options: {
|
|
|
809
802
|
mergeRequested: boolean;
|
|
810
803
|
runTests: boolean;
|
|
811
804
|
runBuild: boolean;
|
|
812
|
-
projectType: ProjectType;
|
|
813
805
|
targets: TReleaseTarget[];
|
|
814
806
|
npmModules: boolean;
|
|
815
807
|
cleanTestArtifacts: boolean;
|
|
@@ -819,14 +811,9 @@ const buildReleasePlan = (options: {
|
|
|
819
811
|
const plan: string[] = ["preflight.branch", "preflight.cleanTree"];
|
|
820
812
|
// package.json files must be what `.smartconfig.json` packageFiles generates.
|
|
821
813
|
if (options.packageFiles) plan.push("preflight.packageFiles");
|
|
822
|
-
//
|
|
823
|
-
//
|
|
824
|
-
|
|
825
|
-
if (
|
|
826
|
-
releaseNeedsIsolatedCheckout(options) &&
|
|
827
|
-
projectTypeHasPackageJson(options.projectType)
|
|
828
|
-
)
|
|
829
|
-
plan.push("preflight.lockfile");
|
|
814
|
+
// A release checkout installs from the committed pnpm lockfile, so the
|
|
815
|
+
// release proves that install before it creates its commit and tag.
|
|
816
|
+
if (releaseNeedsIsolatedCheckout(options)) plan.push("preflight.lockfile");
|
|
830
817
|
// Every npm release reads the registries' dist-tags before it creates
|
|
831
818
|
// anything: `latest` never moves downwards, and a line takes it only when
|
|
832
819
|
// its dist-tag is `latest` and every higher major is a prerelease.
|
|
@@ -1245,16 +1232,9 @@ export const resolveReleaseWorkflow = async (
|
|
|
1245
1232
|
const cleanTestArtifacts = await shouldCleanTestArtifactsOnRelease(
|
|
1246
1233
|
process.cwd(),
|
|
1247
1234
|
);
|
|
1248
|
-
// The
|
|
1249
|
-
//
|
|
1250
|
-
//
|
|
1251
|
-
// questions the way the release commit does for every tracked manifest; the
|
|
1252
|
-
// preflight itself reads the commit. An ignored `package.json` in the working
|
|
1253
|
-
// folder of a Deno-only commit is the one case where the plan lists the step
|
|
1254
|
-
// and the step then does nothing.
|
|
1255
|
-
const projectType = await detectProjectType(process.cwd());
|
|
1256
|
-
// The same holds for the npm package set: the release checkout re-reads it
|
|
1257
|
-
// from the release commit and refuses to publish a different one.
|
|
1235
|
+
// The release worktree is clean before anything is created, so the working
|
|
1236
|
+
// folder's npm package set is the release commit's: the release checkout
|
|
1237
|
+
// re-reads it from the release commit and refuses to publish a different one.
|
|
1258
1238
|
const npmPackages = targets.includes("npm")
|
|
1259
1239
|
? (await planReleaseNpmPackages(process.cwd())).packageSet
|
|
1260
1240
|
: undefined;
|
|
@@ -1270,7 +1250,6 @@ export const resolveReleaseWorkflow = async (
|
|
|
1270
1250
|
mergeRequested,
|
|
1271
1251
|
runTests,
|
|
1272
1252
|
runBuild,
|
|
1273
|
-
projectType,
|
|
1274
1253
|
targets,
|
|
1275
1254
|
npmModules: (npmPackages?.modules.length ?? 0) > 0,
|
|
1276
1255
|
cleanTestArtifacts,
|
|
@@ -1280,7 +1259,6 @@ export const resolveReleaseWorkflow = async (
|
|
|
1280
1259
|
recordRetention: resolveReleaseRecordRetention(
|
|
1281
1260
|
releaseConfig.recordRetention,
|
|
1282
1261
|
),
|
|
1283
|
-
projectType,
|
|
1284
1262
|
targets,
|
|
1285
1263
|
runTests,
|
|
1286
1264
|
runBuild,
|
package/ts/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ import * as paths from '../paths.js';
|
|
|
3
3
|
import { logger } from '../gitzone.logging.js';
|
|
4
4
|
import * as ui from './mod.ui.js';
|
|
5
5
|
|
|
6
|
-
export type ProjectType = 'npm' | 'deno' | 'both' | 'none';
|
|
7
6
|
export type VersionType = 'patch' | 'minor' | 'major';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -33,39 +32,6 @@ export async function detectCurrentBranch(): Promise<string> {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
/**
|
|
37
|
-
* Detects the project type based on presence of package.json and/or deno.json
|
|
38
|
-
* @returns The project type
|
|
39
|
-
*/
|
|
40
|
-
export async function detectProjectType(cwdArg = paths.cwd): Promise<ProjectType> {
|
|
41
|
-
const packageJsonPath = plugins.path.join(cwdArg, 'package.json');
|
|
42
|
-
const denoJsonPath = plugins.path.join(cwdArg, 'deno.json');
|
|
43
|
-
|
|
44
|
-
const hasPackageJson = await plugins.smartfs.file(packageJsonPath).exists();
|
|
45
|
-
const hasDenoJson = await plugins.smartfs.file(denoJsonPath).exists();
|
|
46
|
-
|
|
47
|
-
if (hasPackageJson && hasDenoJson) {
|
|
48
|
-
logger.log('info', 'Detected dual project (npm + deno)');
|
|
49
|
-
return 'both';
|
|
50
|
-
} else if (hasPackageJson) {
|
|
51
|
-
logger.log('info', 'Detected npm project');
|
|
52
|
-
return 'npm';
|
|
53
|
-
} else if (hasDenoJson) {
|
|
54
|
-
logger.log('info', 'Detected deno project');
|
|
55
|
-
return 'deno';
|
|
56
|
-
} else {
|
|
57
|
-
throw new Error('No package.json or deno.json found in current directory');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* A pnpm lockfile, `pnpm install` and `pnpm pack` belong to a project's
|
|
63
|
-
* package.json, so every npm-shaped decision asks this one question.
|
|
64
|
-
*/
|
|
65
|
-
export const projectTypeHasPackageJson = (
|
|
66
|
-
projectTypeArg: ProjectType,
|
|
67
|
-
): boolean => projectTypeArg === 'npm' || projectTypeArg === 'both';
|
|
68
|
-
|
|
69
35
|
/**
|
|
70
36
|
* Parses a semantic version string and bumps it according to the version type
|
|
71
37
|
* @param currentVersion Current version string (e.g., "1.2.3")
|
|
@@ -100,43 +66,37 @@ export function calculateNewVersion(currentVersion: string, versionType: Version
|
|
|
100
66
|
}
|
|
101
67
|
|
|
102
68
|
/**
|
|
103
|
-
*
|
|
104
|
-
|
|
69
|
+
* The project's package.json, which carries the version gitzone commit and release own.
|
|
70
|
+
*/
|
|
71
|
+
const packageJsonPathIn = async (cwdArg: string): Promise<string> => {
|
|
72
|
+
const packageJsonPath = plugins.path.join(cwdArg, 'package.json');
|
|
73
|
+
if (!(await plugins.smartfs.file(packageJsonPath).exists())) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`No package.json found in ${cwdArg}: gitzone commit and release version the package.json.`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return packageJsonPath;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Reads the current version from package.json
|
|
105
83
|
* @returns The current version string
|
|
106
84
|
*/
|
|
107
|
-
export async function readCurrentVersion(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
.read()) as string;
|
|
117
|
-
const packageJson = JSON.parse(content) as { version?: string };
|
|
118
|
-
|
|
119
|
-
if (!packageJson.version) {
|
|
120
|
-
throw new Error('package.json does not contain a version field');
|
|
121
|
-
}
|
|
122
|
-
return packageJson.version;
|
|
123
|
-
} else {
|
|
124
|
-
const denoJsonPath = plugins.path.join(cwdArg, 'deno.json');
|
|
125
|
-
const content = (await plugins.smartfs
|
|
126
|
-
.file(denoJsonPath)
|
|
127
|
-
.encoding('utf8')
|
|
128
|
-
.read()) as string;
|
|
129
|
-
const denoConfig = JSON.parse(content) as { version?: string };
|
|
130
|
-
|
|
131
|
-
if (!denoConfig.version) {
|
|
132
|
-
throw new Error('deno.json does not contain a version field');
|
|
133
|
-
}
|
|
134
|
-
return denoConfig.version;
|
|
85
|
+
export async function readCurrentVersion(cwdArg = paths.cwd): Promise<string> {
|
|
86
|
+
const content = (await plugins.smartfs
|
|
87
|
+
.file(await packageJsonPathIn(cwdArg))
|
|
88
|
+
.encoding('utf8')
|
|
89
|
+
.read()) as string;
|
|
90
|
+
const packageJson = JSON.parse(content) as { version?: string };
|
|
91
|
+
|
|
92
|
+
if (!packageJson.version) {
|
|
93
|
+
throw new Error('package.json does not contain a version field');
|
|
135
94
|
}
|
|
95
|
+
return packageJson.version;
|
|
136
96
|
}
|
|
137
97
|
|
|
138
98
|
/**
|
|
139
|
-
* Updates the version field in a JSON file
|
|
99
|
+
* Updates the version field in a JSON file
|
|
140
100
|
* @param filePath Path to the JSON file
|
|
141
101
|
* @param newVersion The new version to write
|
|
142
102
|
*/
|
|
@@ -154,51 +114,30 @@ export async function updateVersionFile(filePath: string, newVersion: string): P
|
|
|
154
114
|
}
|
|
155
115
|
|
|
156
116
|
/**
|
|
157
|
-
* Updates
|
|
117
|
+
* Updates the package.json version without creating commits or tags.
|
|
118
|
+
* @returns The updated files, relative to `cwdArg`
|
|
158
119
|
*/
|
|
159
120
|
export async function updateProjectVersionFiles(
|
|
160
|
-
projectType: ProjectType,
|
|
161
121
|
newVersion: string,
|
|
162
122
|
cwdArg = paths.cwd,
|
|
163
123
|
): Promise<string[]> {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const denoJsonPath = plugins.path.join(cwdArg, 'deno.json');
|
|
167
|
-
|
|
168
|
-
if (projectType === 'npm' || projectType === 'both') {
|
|
169
|
-
await updateVersionFile(packageJsonPath, newVersion);
|
|
170
|
-
filesToUpdate.push('package.json');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (projectType === 'deno' || projectType === 'both') {
|
|
174
|
-
await updateVersionFile(denoJsonPath, newVersion);
|
|
175
|
-
filesToUpdate.push('deno.json');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return filesToUpdate;
|
|
124
|
+
await updateVersionFile(await packageJsonPathIn(cwdArg), newVersion);
|
|
125
|
+
return ['package.json'];
|
|
179
126
|
}
|
|
180
127
|
|
|
181
128
|
/**
|
|
182
|
-
* Bumps the
|
|
183
|
-
* Handles npm-only, deno-only, and dual projects with unified logic
|
|
184
|
-
* @param projectType The detected project type
|
|
129
|
+
* Bumps the package.json version, then commits and tags it
|
|
185
130
|
* @param versionType The type of version bump
|
|
186
131
|
* @param currentStep The current step number for progress display
|
|
187
132
|
* @param totalSteps The total number of steps for progress display
|
|
188
133
|
* @returns The new version string
|
|
189
134
|
*/
|
|
190
135
|
export async function bumpProjectVersion(
|
|
191
|
-
projectType: ProjectType,
|
|
192
136
|
versionType: VersionType,
|
|
193
137
|
currentStep?: number,
|
|
194
138
|
totalSteps?: number
|
|
195
139
|
): Promise<string> {
|
|
196
|
-
|
|
197
|
-
throw new Error('Cannot bump version: no package.json or deno.json found');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const projectEmoji = projectType === 'npm' ? '📦' : projectType === 'deno' ? '🦕' : '🔀';
|
|
201
|
-
const description = `🏷️ Bumping version (${projectEmoji} ${projectType})`;
|
|
140
|
+
const description = '🏷️ Bumping version (📦 package.json)';
|
|
202
141
|
|
|
203
142
|
if (currentStep && totalSteps) {
|
|
204
143
|
ui.printStep(currentStep, totalSteps, description, 'in-progress');
|
|
@@ -211,7 +150,7 @@ export async function bumpProjectVersion(
|
|
|
211
150
|
|
|
212
151
|
try {
|
|
213
152
|
// 1. Read current version
|
|
214
|
-
const currentVersion = await readCurrentVersion(
|
|
153
|
+
const currentVersion = await readCurrentVersion();
|
|
215
154
|
|
|
216
155
|
// 2. Calculate new version (reuse existing function!)
|
|
217
156
|
const newVersion = calculateNewVersion(currentVersion, versionType);
|
|
@@ -219,7 +158,7 @@ export async function bumpProjectVersion(
|
|
|
219
158
|
logger.log('info', `Bumping version: ${currentVersion} → ${newVersion}`);
|
|
220
159
|
|
|
221
160
|
// 3. Determine which files to update
|
|
222
|
-
const filesToUpdate = await updateProjectVersionFiles(
|
|
161
|
+
const filesToUpdate = await updateProjectVersionFiles(newVersion);
|
|
223
162
|
|
|
224
163
|
// 4. Stage all updated files
|
|
225
164
|
await smartshellInstance.exec(`git add ${filesToUpdate.join(' ')}`);
|
package/ts/mod_commit/mod.ui.ts
CHANGED
|
@@ -163,10 +163,6 @@ function getProjectTypeEmoji(projectType: string): string {
|
|
|
163
163
|
switch (projectType) {
|
|
164
164
|
case 'npm':
|
|
165
165
|
return '📦 npm';
|
|
166
|
-
case 'deno':
|
|
167
|
-
return '🦕 Deno';
|
|
168
|
-
case 'both':
|
|
169
|
-
return '🔀 npm + Deno';
|
|
170
166
|
default:
|
|
171
167
|
return '❓ Unknown';
|
|
172
168
|
}
|
package/ts/mod_config/index.ts
CHANGED
|
@@ -44,6 +44,11 @@ import {
|
|
|
44
44
|
type IReleasePrerelease,
|
|
45
45
|
} from "../mod_release/helpers.releaseversion.js";
|
|
46
46
|
import { getSealedReleaseConfigError } from "../helpers.sealedrelease.js";
|
|
47
|
+
import {
|
|
48
|
+
getManagedAssetsMigrationErrors,
|
|
49
|
+
managedAssetKinds,
|
|
50
|
+
readBinaryBuild,
|
|
51
|
+
} from "../helpers.managedassets.js";
|
|
47
52
|
import {
|
|
48
53
|
getReleaseDockerAliasPolicy,
|
|
49
54
|
latestDistTag,
|
|
@@ -1257,6 +1262,22 @@ async function validatePackageFilesConfig(
|
|
|
1257
1262
|
});
|
|
1258
1263
|
return;
|
|
1259
1264
|
}
|
|
1265
|
+
// The binary set derives from the managed assets, whose removed keys the
|
|
1266
|
+
// managed assets findings already name once each.
|
|
1267
|
+
const assets = isPlainObject(cliConfig.assets) ? cliConfig.assets : undefined;
|
|
1268
|
+
if (
|
|
1269
|
+
assets &&
|
|
1270
|
+
assets.enabled !== false &&
|
|
1271
|
+
getManagedAssetsMigrationErrors(assets).length > 0
|
|
1272
|
+
) {
|
|
1273
|
+
findings.push({
|
|
1274
|
+
level: "warn",
|
|
1275
|
+
message:
|
|
1276
|
+
"package.json files is not checked while @git.zone/cli.assets uses removed keys",
|
|
1277
|
+
fix: "Migrate @git.zone/cli.assets first; the managed assets findings name each removed key.",
|
|
1278
|
+
});
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1260
1281
|
let packageJson: Record<string, any>;
|
|
1261
1282
|
try {
|
|
1262
1283
|
packageJson = await readPackageJson();
|
|
@@ -2200,6 +2221,17 @@ async function validateAssetsConfig(
|
|
|
2200
2221
|
findings.push({ level: "ok", message: "Managed assets are disabled" });
|
|
2201
2222
|
return;
|
|
2202
2223
|
}
|
|
2224
|
+
const migrationErrors = getManagedAssetsMigrationErrors(rawAssetsConfig);
|
|
2225
|
+
if (migrationErrors.length > 0) {
|
|
2226
|
+
for (const message of migrationErrors) {
|
|
2227
|
+
findings.push({
|
|
2228
|
+
level: "error",
|
|
2229
|
+
message,
|
|
2230
|
+
fix: "Migrate @git.zone/cli.assets as the message says.",
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2203
2235
|
if (rawAssetsConfig.kind === "tspackRelease") {
|
|
2204
2236
|
const error = getSealedReleaseConfigError(rawAssetsConfig.sealedRelease);
|
|
2205
2237
|
findings.push(
|
|
@@ -2217,11 +2249,11 @@ async function validateAssetsConfig(
|
|
|
2217
2249
|
);
|
|
2218
2250
|
return;
|
|
2219
2251
|
}
|
|
2220
|
-
if (rawAssetsConfig.kind !== "
|
|
2252
|
+
if (rawAssetsConfig.kind !== "binaryCli") {
|
|
2221
2253
|
findings.push({
|
|
2222
2254
|
level: "error",
|
|
2223
2255
|
message: `Unsupported managed asset kind: ${formatValue(rawAssetsConfig.kind)}`,
|
|
2224
|
-
fix:
|
|
2256
|
+
fix: `Use kind ${managedAssetKinds.join(" or ")}, or disable managed assets.`,
|
|
2225
2257
|
});
|
|
2226
2258
|
return;
|
|
2227
2259
|
}
|
|
@@ -2230,35 +2262,27 @@ async function validateAssetsConfig(
|
|
|
2230
2262
|
if (typeof cliName !== "string" || !cliName.trim()) {
|
|
2231
2263
|
findings.push({
|
|
2232
2264
|
level: "error",
|
|
2233
|
-
message: "
|
|
2265
|
+
message: "binaryCli assets require cliName",
|
|
2234
2266
|
fix: "Set @git.zone/cli.assets.cliName.",
|
|
2235
2267
|
});
|
|
2236
2268
|
} else {
|
|
2237
2269
|
findings.push({
|
|
2238
2270
|
level: "ok",
|
|
2239
|
-
message: `Managed
|
|
2271
|
+
message: `Managed binaryCli assets target ${cliName}`,
|
|
2240
2272
|
});
|
|
2241
2273
|
}
|
|
2242
2274
|
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
isPlainObject(rawAssetsConfig.binary) &&
|
|
2246
|
-
Array.isArray(rawAssetsConfig.binary.targets)
|
|
2247
|
-
? rawAssetsConfig.binary.targets
|
|
2248
|
-
: isPlainObject(tsdenoConfig) &&
|
|
2249
|
-
Array.isArray(tsdenoConfig.compileTargets)
|
|
2250
|
-
? tsdenoConfig.compileTargets
|
|
2251
|
-
: [];
|
|
2252
|
-
if (binaryTargets.length === 0) {
|
|
2275
|
+
try {
|
|
2276
|
+
const binaryBuild = await readBinaryBuild(process.cwd(), smartconfigData);
|
|
2253
2277
|
findings.push({
|
|
2254
|
-
level: "
|
|
2255
|
-
message:
|
|
2256
|
-
fix: "Add @git.zone/tsdeno.compileTargets or @git.zone/cli.assets.binary.targets.",
|
|
2278
|
+
level: "ok",
|
|
2279
|
+
message: `Managed assets release ${binaryBuild.targets.length} @git.zone/tssea executable(s) from ${binaryBuild.outDir}`,
|
|
2257
2280
|
});
|
|
2258
|
-
}
|
|
2281
|
+
} catch (error) {
|
|
2259
2282
|
findings.push({
|
|
2260
|
-
level: "
|
|
2261
|
-
message:
|
|
2283
|
+
level: "error",
|
|
2284
|
+
message: error instanceof Error ? error.message : String(error),
|
|
2285
|
+
fix: "Configure and install @git.zone/tssea as the message says.",
|
|
2262
2286
|
});
|
|
2263
2287
|
}
|
|
2264
2288
|
|
|
@@ -2825,35 +2849,23 @@ async function validateDetectedProjectType(
|
|
|
2825
2849
|
findings: IDoctorFinding[],
|
|
2826
2850
|
): Promise<void> {
|
|
2827
2851
|
const packageJsonPath = plugins.path.join(process.cwd(), "package.json");
|
|
2828
|
-
const denoJsonPath = plugins.path.join(process.cwd(), "deno.json");
|
|
2829
2852
|
const hasPackageJson = await plugins.smartfs.file(packageJsonPath).exists();
|
|
2830
|
-
const hasDenoJson = await plugins.smartfs.file(denoJsonPath).exists();
|
|
2831
2853
|
|
|
2832
|
-
if (!hasPackageJson
|
|
2854
|
+
if (!hasPackageJson) {
|
|
2833
2855
|
findings.push({
|
|
2834
2856
|
level: "warn",
|
|
2835
|
-
message: "Could not detect package.json
|
|
2857
|
+
message: "Could not detect package.json",
|
|
2836
2858
|
fix: "Run this command from a project root.",
|
|
2837
2859
|
});
|
|
2838
2860
|
return;
|
|
2839
2861
|
}
|
|
2840
2862
|
|
|
2841
|
-
if (
|
|
2863
|
+
if (validProjectTypes.includes(cliConfig.projectType)) {
|
|
2842
2864
|
findings.push({
|
|
2843
2865
|
level: "ok",
|
|
2844
2866
|
message:
|
|
2845
2867
|
"Detected project files match configured npm-compatible project type",
|
|
2846
2868
|
});
|
|
2847
|
-
return;
|
|
2848
|
-
}
|
|
2849
|
-
|
|
2850
|
-
if (hasDenoJson && !hasPackageJson) {
|
|
2851
|
-
findings.push({
|
|
2852
|
-
level: "warn",
|
|
2853
|
-
message:
|
|
2854
|
-
"Detected a Deno-only project, but guided config supports npm-compatible project types",
|
|
2855
|
-
fix: "Use `gitzone config set projectType npm|service|wcc|website` only for npm-compatible projects.",
|
|
2856
|
-
});
|
|
2857
2869
|
}
|
|
2858
2870
|
}
|
|
2859
2871
|
|