@git.zone/cli 2.13.15 → 2.14.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_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/gitzone.cli.js +46 -35
- package/dist_ts/helpers.climode.d.ts +22 -0
- package/dist_ts/helpers.climode.js +158 -0
- package/dist_ts/helpers.smartconfig.d.ts +11 -0
- package/dist_ts/helpers.smartconfig.js +139 -0
- package/dist_ts/mod_commit/index.d.ts +2 -0
- package/dist_ts/mod_commit/index.js +204 -92
- package/dist_ts/mod_config/index.d.ts +7 -2
- package/dist_ts/mod_config/index.js +390 -176
- package/dist_ts/mod_format/classes.formatcontext.d.ts +11 -2
- package/dist_ts/mod_format/classes.formatcontext.js +14 -4
- package/dist_ts/mod_format/formatters/packagejson.formatter.js +1 -67
- package/dist_ts/mod_format/formatters/smartconfig.formatter.d.ts +2 -2
- package/dist_ts/mod_format/formatters/smartconfig.formatter.js +46 -39
- package/dist_ts/mod_format/index.d.ts +4 -1
- package/dist_ts/mod_format/index.js +221 -75
- package/dist_ts/mod_format/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_format/mod.plugins.js +2 -3
- package/dist_ts/mod_services/index.d.ts +2 -0
- package/dist_ts/mod_services/index.js +366 -168
- package/dist_ts/mod_standard/index.d.ts +3 -1
- package/dist_ts/mod_standard/index.js +159 -59
- package/package.json +1 -1
- package/readme.hints.md +25 -32
- package/readme.md +87 -65
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/gitzone.cli.ts +50 -38
- package/ts/helpers.climode.ts +212 -0
- package/ts/helpers.smartconfig.ts +192 -0
- package/ts/mod_commit/index.ts +325 -98
- package/ts/mod_config/index.ts +490 -182
- package/ts/mod_format/classes.formatcontext.ts +20 -3
- package/ts/mod_format/formatters/packagejson.formatter.ts +0 -91
- package/ts/mod_format/formatters/smartconfig.formatter.ts +55 -39
- package/ts/mod_format/index.ts +279 -90
- package/ts/mod_format/mod.plugins.ts +0 -2
- package/ts/mod_services/index.ts +550 -183
- package/ts/mod_standard/index.ts +191 -58
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
import * as plugins from
|
|
2
|
-
import { FormatStats } from
|
|
1
|
+
import * as plugins from "./mod.plugins.js";
|
|
2
|
+
import { FormatStats } from "./classes.formatstats.js";
|
|
3
|
+
|
|
4
|
+
interface IFormatContextOptions {
|
|
5
|
+
interactive?: boolean;
|
|
6
|
+
jsonOutput?: boolean;
|
|
7
|
+
}
|
|
3
8
|
|
|
4
9
|
export class FormatContext {
|
|
5
10
|
private formatStats: FormatStats;
|
|
11
|
+
private interactive: boolean;
|
|
12
|
+
private jsonOutput: boolean;
|
|
6
13
|
|
|
7
|
-
constructor() {
|
|
14
|
+
constructor(options: IFormatContextOptions = {}) {
|
|
8
15
|
this.formatStats = new FormatStats();
|
|
16
|
+
this.interactive = options.interactive ?? true;
|
|
17
|
+
this.jsonOutput = options.jsonOutput ?? false;
|
|
9
18
|
}
|
|
10
19
|
|
|
11
20
|
getFormatStats(): FormatStats {
|
|
12
21
|
return this.formatStats;
|
|
13
22
|
}
|
|
23
|
+
|
|
24
|
+
isInteractive(): boolean {
|
|
25
|
+
return this.interactive;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
isJsonOutput(): boolean {
|
|
29
|
+
return this.jsonOutput;
|
|
30
|
+
}
|
|
14
31
|
}
|
|
@@ -4,77 +4,6 @@ import * as plugins from '../mod.plugins.js';
|
|
|
4
4
|
import * as paths from '../../paths.js';
|
|
5
5
|
import { logger, logVerbose } from '../../gitzone.logging.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Ensures a certain dependency exists or is excluded
|
|
9
|
-
*/
|
|
10
|
-
const ensureDependency = async (
|
|
11
|
-
packageJsonObject: any,
|
|
12
|
-
position: 'dep' | 'devDep' | 'everywhere',
|
|
13
|
-
constraint: 'exclude' | 'include' | 'latest',
|
|
14
|
-
dependencyArg: string,
|
|
15
|
-
): Promise<void> => {
|
|
16
|
-
// Parse package name and version, handling scoped packages like @scope/name@version
|
|
17
|
-
const isScoped = dependencyArg.startsWith('@');
|
|
18
|
-
const lastAtIndex = dependencyArg.lastIndexOf('@');
|
|
19
|
-
|
|
20
|
-
// For scoped packages, the version @ must come after the /
|
|
21
|
-
// For unscoped packages, any @ indicates a version
|
|
22
|
-
const hasVersion = isScoped
|
|
23
|
-
? lastAtIndex > dependencyArg.indexOf('/')
|
|
24
|
-
: lastAtIndex >= 0;
|
|
25
|
-
|
|
26
|
-
const packageName = hasVersion ? dependencyArg.slice(0, lastAtIndex) : dependencyArg;
|
|
27
|
-
const version = hasVersion ? dependencyArg.slice(lastAtIndex + 1) : 'latest';
|
|
28
|
-
|
|
29
|
-
const targetSections: string[] = [];
|
|
30
|
-
|
|
31
|
-
switch (position) {
|
|
32
|
-
case 'dep':
|
|
33
|
-
targetSections.push('dependencies');
|
|
34
|
-
break;
|
|
35
|
-
case 'devDep':
|
|
36
|
-
targetSections.push('devDependencies');
|
|
37
|
-
break;
|
|
38
|
-
case 'everywhere':
|
|
39
|
-
targetSections.push('dependencies', 'devDependencies');
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
for (const section of targetSections) {
|
|
44
|
-
if (!packageJsonObject[section]) {
|
|
45
|
-
packageJsonObject[section] = {};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
switch (constraint) {
|
|
49
|
-
case 'exclude':
|
|
50
|
-
delete packageJsonObject[section][packageName];
|
|
51
|
-
break;
|
|
52
|
-
case 'include':
|
|
53
|
-
if (!packageJsonObject[section][packageName]) {
|
|
54
|
-
packageJsonObject[section][packageName] =
|
|
55
|
-
version === 'latest' ? '^1.0.0' : version;
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
case 'latest':
|
|
59
|
-
try {
|
|
60
|
-
const registry = new plugins.smartnpm.NpmRegistry();
|
|
61
|
-
const packageInfo = await registry.getPackageInfo(packageName);
|
|
62
|
-
const latestVersion = packageInfo['dist-tags'].latest;
|
|
63
|
-
packageJsonObject[section][packageName] = `^${latestVersion}`;
|
|
64
|
-
} catch (error) {
|
|
65
|
-
logVerbose(
|
|
66
|
-
`Could not fetch latest version for ${packageName}, using existing or default`,
|
|
67
|
-
);
|
|
68
|
-
if (!packageJsonObject[section][packageName]) {
|
|
69
|
-
packageJsonObject[section][packageName] =
|
|
70
|
-
version === 'latest' ? '^1.0.0' : version;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
7
|
export class PackageJsonFormatter extends BaseFormatter {
|
|
79
8
|
get name(): string {
|
|
80
9
|
return 'packagejson';
|
|
@@ -141,11 +70,6 @@ export class PackageJsonFormatter extends BaseFormatter {
|
|
|
141
70
|
packageJson.scripts.build = `echo "Not needed for now"`;
|
|
142
71
|
}
|
|
143
72
|
|
|
144
|
-
// Ensure buildDocs script exists
|
|
145
|
-
if (!packageJson.scripts.buildDocs) {
|
|
146
|
-
packageJson.scripts.buildDocs = `tsdoc`;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
73
|
// Set files array
|
|
150
74
|
packageJson.files = [
|
|
151
75
|
'ts/**/*',
|
|
@@ -160,21 +84,6 @@ export class PackageJsonFormatter extends BaseFormatter {
|
|
|
160
84
|
'readme.md',
|
|
161
85
|
];
|
|
162
86
|
|
|
163
|
-
// Handle dependencies
|
|
164
|
-
await ensureDependency(
|
|
165
|
-
packageJson,
|
|
166
|
-
'devDep',
|
|
167
|
-
'exclude',
|
|
168
|
-
'@push.rocks/tapbundle',
|
|
169
|
-
);
|
|
170
|
-
await ensureDependency(packageJson, 'devDep', 'latest', '@git.zone/tstest');
|
|
171
|
-
await ensureDependency(
|
|
172
|
-
packageJson,
|
|
173
|
-
'devDep',
|
|
174
|
-
'latest',
|
|
175
|
-
'@git.zone/tsbuild',
|
|
176
|
-
);
|
|
177
|
-
|
|
178
87
|
// Set pnpm overrides from assets
|
|
179
88
|
try {
|
|
180
89
|
const overridesContent = (await plugins.smartfs
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BaseFormatter } from
|
|
2
|
-
import type { IPlannedChange } from
|
|
3
|
-
import * as plugins from
|
|
4
|
-
import { logger, logVerbose } from
|
|
1
|
+
import { BaseFormatter } from "../classes.baseformatter.js";
|
|
2
|
+
import type { IPlannedChange } from "../interfaces.format.js";
|
|
3
|
+
import * as plugins from "../mod.plugins.js";
|
|
4
|
+
import { logger, logVerbose } from "../../gitzone.logging.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Migrates .smartconfig.json from old namespace keys to new package-scoped keys
|
|
@@ -9,11 +9,11 @@ import { logger, logVerbose } from '../../gitzone.logging.js';
|
|
|
9
9
|
const migrateNamespaceKeys = (smartconfigJson: any): boolean => {
|
|
10
10
|
let migrated = false;
|
|
11
11
|
const migrations = [
|
|
12
|
-
{ oldKey:
|
|
13
|
-
{ oldKey:
|
|
14
|
-
{ oldKey:
|
|
15
|
-
{ oldKey:
|
|
16
|
-
{ oldKey:
|
|
12
|
+
{ oldKey: "gitzone", newKey: "@git.zone/cli" },
|
|
13
|
+
{ oldKey: "tsdoc", newKey: "@git.zone/tsdoc" },
|
|
14
|
+
{ oldKey: "npmdocker", newKey: "@git.zone/tsdocker" },
|
|
15
|
+
{ oldKey: "npmci", newKey: "@ship.zone/szci" },
|
|
16
|
+
{ oldKey: "szci", newKey: "@ship.zone/szci" },
|
|
17
17
|
];
|
|
18
18
|
for (const { oldKey, newKey } of migrations) {
|
|
19
19
|
if (smartconfigJson[oldKey]) {
|
|
@@ -36,36 +36,37 @@ const migrateNamespaceKeys = (smartconfigJson: any): boolean => {
|
|
|
36
36
|
* Migrates npmAccessLevel from @ship.zone/szci to @git.zone/cli.release.accessLevel
|
|
37
37
|
*/
|
|
38
38
|
const migrateAccessLevel = (smartconfigJson: any): boolean => {
|
|
39
|
-
const szciConfig = smartconfigJson[
|
|
39
|
+
const szciConfig = smartconfigJson["@ship.zone/szci"];
|
|
40
40
|
|
|
41
41
|
if (!szciConfig?.npmAccessLevel) {
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const gitzoneConfig = smartconfigJson[
|
|
45
|
+
const gitzoneConfig = smartconfigJson["@git.zone/cli"] || {};
|
|
46
46
|
if (gitzoneConfig?.release?.accessLevel) {
|
|
47
47
|
delete szciConfig.npmAccessLevel;
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
if (!smartconfigJson[
|
|
52
|
-
smartconfigJson[
|
|
51
|
+
if (!smartconfigJson["@git.zone/cli"]) {
|
|
52
|
+
smartconfigJson["@git.zone/cli"] = {};
|
|
53
53
|
}
|
|
54
|
-
if (!smartconfigJson[
|
|
55
|
-
smartconfigJson[
|
|
54
|
+
if (!smartconfigJson["@git.zone/cli"].release) {
|
|
55
|
+
smartconfigJson["@git.zone/cli"].release = {};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
smartconfigJson[
|
|
58
|
+
smartconfigJson["@git.zone/cli"].release.accessLevel =
|
|
59
|
+
szciConfig.npmAccessLevel;
|
|
59
60
|
delete szciConfig.npmAccessLevel;
|
|
60
61
|
|
|
61
62
|
return true;
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
const CONFIG_FILE =
|
|
65
|
+
const CONFIG_FILE = ".smartconfig.json";
|
|
65
66
|
|
|
66
67
|
export class SmartconfigFormatter extends BaseFormatter {
|
|
67
68
|
get name(): string {
|
|
68
|
-
return
|
|
69
|
+
return "smartconfig";
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
async analyze(): Promise<IPlannedChange[]> {
|
|
@@ -76,13 +77,13 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
76
77
|
// This formatter only operates on .smartconfig.json.
|
|
77
78
|
const exists = await plugins.smartfs.file(CONFIG_FILE).exists();
|
|
78
79
|
if (!exists) {
|
|
79
|
-
logVerbose(
|
|
80
|
+
logVerbose(".smartconfig.json does not exist, skipping");
|
|
80
81
|
return changes;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
const currentContent = (await plugins.smartfs
|
|
84
85
|
.file(CONFIG_FILE)
|
|
85
|
-
.encoding(
|
|
86
|
+
.encoding("utf8")
|
|
86
87
|
.read()) as string;
|
|
87
88
|
|
|
88
89
|
const smartconfigJson = JSON.parse(currentContent);
|
|
@@ -92,21 +93,21 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
92
93
|
migrateAccessLevel(smartconfigJson);
|
|
93
94
|
|
|
94
95
|
// Ensure namespaces exist
|
|
95
|
-
if (!smartconfigJson[
|
|
96
|
-
smartconfigJson[
|
|
96
|
+
if (!smartconfigJson["@git.zone/cli"]) {
|
|
97
|
+
smartconfigJson["@git.zone/cli"] = {};
|
|
97
98
|
}
|
|
98
|
-
if (!smartconfigJson[
|
|
99
|
-
smartconfigJson[
|
|
99
|
+
if (!smartconfigJson["@ship.zone/szci"]) {
|
|
100
|
+
smartconfigJson["@ship.zone/szci"] = {};
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
const newContent = JSON.stringify(smartconfigJson, null, 2);
|
|
103
104
|
|
|
104
105
|
if (newContent !== currentContent) {
|
|
105
106
|
changes.push({
|
|
106
|
-
type:
|
|
107
|
+
type: "modify",
|
|
107
108
|
path: CONFIG_FILE,
|
|
108
109
|
module: this.name,
|
|
109
|
-
description:
|
|
110
|
+
description: "Migrate and format .smartconfig.json",
|
|
110
111
|
content: newContent,
|
|
111
112
|
});
|
|
112
113
|
}
|
|
@@ -115,26 +116,41 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
async applyChange(change: IPlannedChange): Promise<void> {
|
|
118
|
-
if (change.type !==
|
|
119
|
+
if (change.type !== "modify" || !change.content) return;
|
|
119
120
|
|
|
120
121
|
const smartconfigJson = JSON.parse(change.content);
|
|
121
122
|
|
|
122
123
|
// Check for missing required module information
|
|
123
124
|
const expectedRepoInformation: string[] = [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
"projectType",
|
|
126
|
+
"module.githost",
|
|
127
|
+
"module.gitscope",
|
|
128
|
+
"module.gitrepo",
|
|
129
|
+
"module.description",
|
|
130
|
+
"module.npmPackagename",
|
|
131
|
+
"module.license",
|
|
131
132
|
];
|
|
132
133
|
|
|
133
134
|
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
135
|
+
const missingRepoInformation = expectedRepoInformation.filter(
|
|
136
|
+
(expectedRepoInformationItem) => {
|
|
137
|
+
return !plugins.smartobject.smartGet(
|
|
138
|
+
smartconfigJson["@git.zone/cli"],
|
|
139
|
+
expectedRepoInformationItem,
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
if (missingRepoInformation.length > 0 && !this.context.isInteractive()) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Missing required .smartconfig.json fields: ${missingRepoInformation.join(", ")}`,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
134
150
|
for (const expectedRepoInformationItem of expectedRepoInformation) {
|
|
135
151
|
if (
|
|
136
152
|
!plugins.smartobject.smartGet(
|
|
137
|
-
smartconfigJson[
|
|
153
|
+
smartconfigJson["@git.zone/cli"],
|
|
138
154
|
expectedRepoInformationItem,
|
|
139
155
|
)
|
|
140
156
|
) {
|
|
@@ -142,8 +158,8 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
142
158
|
{
|
|
143
159
|
message: `What is the value of ${expectedRepoInformationItem}`,
|
|
144
160
|
name: expectedRepoInformationItem,
|
|
145
|
-
type:
|
|
146
|
-
default:
|
|
161
|
+
type: "input",
|
|
162
|
+
default: "undefined variable",
|
|
147
163
|
},
|
|
148
164
|
]);
|
|
149
165
|
}
|
|
@@ -156,7 +172,7 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
156
172
|
);
|
|
157
173
|
if (cliProvidedValue) {
|
|
158
174
|
plugins.smartobject.smartAdd(
|
|
159
|
-
smartconfigJson[
|
|
175
|
+
smartconfigJson["@git.zone/cli"],
|
|
160
176
|
expectedRepoInformationItem,
|
|
161
177
|
cliProvidedValue,
|
|
162
178
|
);
|
|
@@ -165,6 +181,6 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
165
181
|
|
|
166
182
|
const finalContent = JSON.stringify(smartconfigJson, null, 2);
|
|
167
183
|
await this.modifyFile(change.path, finalContent);
|
|
168
|
-
logger.log(
|
|
184
|
+
logger.log("info", "Updated .smartconfig.json");
|
|
169
185
|
}
|
|
170
186
|
}
|