@git.zone/cli 2.2.0 → 2.3.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/npmextra/npmextra.json +6 -4
- package/assets/templates/service/npmextra.json +2 -2
- package/assets/templates/website/npmextra.json +2 -2
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.gitzoneconfig.js +11 -5
- package/dist_ts/gitzone.cli.js +8 -1
- package/dist_ts/mod_commit/index.js +80 -8
- package/dist_ts/mod_commit/mod.ui.d.ts +2 -0
- package/dist_ts/mod_commit/mod.ui.js +11 -2
- package/dist_ts/mod_config/classes.releaseconfig.d.ts +60 -0
- package/dist_ts/mod_config/classes.releaseconfig.js +131 -0
- package/dist_ts/mod_config/index.d.ts +3 -0
- package/dist_ts/mod_config/index.js +248 -0
- package/dist_ts/mod_config/mod.plugins.d.ts +2 -0
- package/dist_ts/mod_config/mod.plugins.js +4 -0
- package/dist_ts/mod_format/format.npmextra.js +63 -7
- package/dist_ts/mod_format/format.packagejson.js +2 -2
- package/dist_ts/mod_format/index.js +2 -2
- package/dist_ts/mod_services/classes.servicemanager.js +6 -6
- package/package.json +9 -9
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.gitzoneconfig.ts +14 -6
- package/ts/gitzone.cli.ts +8 -0
- package/ts/mod_commit/index.ts +82 -9
- package/ts/mod_commit/mod.ui.ts +12 -1
- package/ts/mod_config/classes.releaseconfig.ts +166 -0
- package/ts/mod_config/index.ts +277 -0
- package/ts/mod_config/mod.plugins.ts +3 -0
- package/ts/mod_format/format.npmextra.ts +71 -6
- package/ts/mod_format/format.packagejson.ts +1 -1
- package/ts/mod_format/index.ts +1 -1
- package/ts/mod_services/classes.servicemanager.ts +5 -5
- package/dist_ts/gitzone.config.d.ts +0 -28
- package/dist_ts/gitzone.config.js +0 -21
- package/dist_ts/gitzone.monitor.d.ts +0 -1
- package/dist_ts/gitzone.monitor.js +0 -2
- package/dist_ts/gitzone.paths.d.ts +0 -4
- package/dist_ts/gitzone.paths.js +0 -6
- package/dist_ts/gitzone.plugins.d.ts +0 -10
- package/dist_ts/gitzone.plugins.js +0 -11
- package/dist_ts/mod_format/format.classes.project.d.ts +0 -8
- package/dist_ts/mod_format/format.classes.project.js +0 -20
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as plugins from './mod.plugins.js';
|
|
2
|
+
|
|
3
|
+
export type TAccessLevel = 'public' | 'private';
|
|
4
|
+
|
|
5
|
+
export interface IReleaseConfig {
|
|
6
|
+
registries: string[];
|
|
7
|
+
accessLevel: TAccessLevel;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Manages release configuration stored in npmextra.json
|
|
12
|
+
* under @git.zone/cli.release namespace
|
|
13
|
+
*/
|
|
14
|
+
export class ReleaseConfig {
|
|
15
|
+
private cwd: string;
|
|
16
|
+
private config: IReleaseConfig;
|
|
17
|
+
|
|
18
|
+
constructor(cwd: string = process.cwd()) {
|
|
19
|
+
this.cwd = cwd;
|
|
20
|
+
this.config = { registries: [], accessLevel: 'public' };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a ReleaseConfig instance from current working directory
|
|
25
|
+
*/
|
|
26
|
+
public static async fromCwd(cwd: string = process.cwd()): Promise<ReleaseConfig> {
|
|
27
|
+
const instance = new ReleaseConfig(cwd);
|
|
28
|
+
await instance.load();
|
|
29
|
+
return instance;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Load configuration from npmextra.json
|
|
34
|
+
*/
|
|
35
|
+
public async load(): Promise<void> {
|
|
36
|
+
const npmextraInstance = new plugins.npmextra.Npmextra(this.cwd);
|
|
37
|
+
const gitzoneConfig = npmextraInstance.dataFor<any>('@git.zone/cli', {});
|
|
38
|
+
|
|
39
|
+
// Also check szci for backward compatibility
|
|
40
|
+
const szciConfig = npmextraInstance.dataFor<any>('@ship.zone/szci', {});
|
|
41
|
+
|
|
42
|
+
this.config = {
|
|
43
|
+
registries: gitzoneConfig?.release?.registries || [],
|
|
44
|
+
accessLevel: gitzoneConfig?.release?.accessLevel || szciConfig?.npmAccessLevel || 'public',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Save configuration to npmextra.json
|
|
50
|
+
*/
|
|
51
|
+
public async save(): Promise<void> {
|
|
52
|
+
const npmextraPath = plugins.path.join(this.cwd, 'npmextra.json');
|
|
53
|
+
let npmextraData: any = {};
|
|
54
|
+
|
|
55
|
+
// Read existing npmextra.json
|
|
56
|
+
if (await plugins.smartfs.file(npmextraPath).exists()) {
|
|
57
|
+
const content = await plugins.smartfs.file(npmextraPath).encoding('utf8').read();
|
|
58
|
+
npmextraData = JSON.parse(content as string);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Ensure @git.zone/cli namespace exists
|
|
62
|
+
if (!npmextraData['@git.zone/cli']) {
|
|
63
|
+
npmextraData['@git.zone/cli'] = {};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Ensure release object exists
|
|
67
|
+
if (!npmextraData['@git.zone/cli'].release) {
|
|
68
|
+
npmextraData['@git.zone/cli'].release = {};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Update registries and accessLevel
|
|
72
|
+
npmextraData['@git.zone/cli'].release.registries = this.config.registries;
|
|
73
|
+
npmextraData['@git.zone/cli'].release.accessLevel = this.config.accessLevel;
|
|
74
|
+
|
|
75
|
+
// Write back to file
|
|
76
|
+
await plugins.smartfs
|
|
77
|
+
.file(npmextraPath)
|
|
78
|
+
.encoding('utf8')
|
|
79
|
+
.write(JSON.stringify(npmextraData, null, 2));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get all configured registries
|
|
84
|
+
*/
|
|
85
|
+
public getRegistries(): string[] {
|
|
86
|
+
return [...this.config.registries];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Check if any registries are configured
|
|
91
|
+
*/
|
|
92
|
+
public hasRegistries(): boolean {
|
|
93
|
+
return this.config.registries.length > 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Add a registry URL
|
|
98
|
+
* @returns true if added, false if already exists
|
|
99
|
+
*/
|
|
100
|
+
public addRegistry(url: string): boolean {
|
|
101
|
+
const normalizedUrl = this.normalizeUrl(url);
|
|
102
|
+
|
|
103
|
+
if (this.config.registries.includes(normalizedUrl)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.config.registries.push(normalizedUrl);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Remove a registry URL
|
|
113
|
+
* @returns true if removed, false if not found
|
|
114
|
+
*/
|
|
115
|
+
public removeRegistry(url: string): boolean {
|
|
116
|
+
const normalizedUrl = this.normalizeUrl(url);
|
|
117
|
+
const index = this.config.registries.indexOf(normalizedUrl);
|
|
118
|
+
|
|
119
|
+
if (index === -1) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.config.registries.splice(index, 1);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Clear all registries
|
|
129
|
+
*/
|
|
130
|
+
public clearRegistries(): void {
|
|
131
|
+
this.config.registries = [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get the npm access level
|
|
136
|
+
*/
|
|
137
|
+
public getAccessLevel(): TAccessLevel {
|
|
138
|
+
return this.config.accessLevel;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Set the npm access level
|
|
143
|
+
*/
|
|
144
|
+
public setAccessLevel(level: TAccessLevel): void {
|
|
145
|
+
this.config.accessLevel = level;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Normalize a registry URL (ensure it has https:// prefix)
|
|
150
|
+
*/
|
|
151
|
+
private normalizeUrl(url: string): string {
|
|
152
|
+
let normalized = url.trim();
|
|
153
|
+
|
|
154
|
+
// Add https:// if no protocol specified
|
|
155
|
+
if (!normalized.startsWith('http://') && !normalized.startsWith('https://')) {
|
|
156
|
+
normalized = `https://${normalized}`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Remove trailing slash
|
|
160
|
+
if (normalized.endsWith('/')) {
|
|
161
|
+
normalized = normalized.slice(0, -1);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return normalized;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// gitzone config - manage release registry configuration
|
|
2
|
+
|
|
3
|
+
import * as plugins from './mod.plugins.js';
|
|
4
|
+
import { ReleaseConfig } from './classes.releaseconfig.js';
|
|
5
|
+
|
|
6
|
+
export { ReleaseConfig };
|
|
7
|
+
|
|
8
|
+
export const run = async (argvArg: any) => {
|
|
9
|
+
const command = argvArg._?.[1];
|
|
10
|
+
const value = argvArg._?.[2];
|
|
11
|
+
|
|
12
|
+
// If no command provided, show interactive menu
|
|
13
|
+
if (!command) {
|
|
14
|
+
await handleInteractiveMenu();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
switch (command) {
|
|
19
|
+
case 'show':
|
|
20
|
+
await handleShow();
|
|
21
|
+
break;
|
|
22
|
+
case 'add':
|
|
23
|
+
await handleAdd(value);
|
|
24
|
+
break;
|
|
25
|
+
case 'remove':
|
|
26
|
+
await handleRemove(value);
|
|
27
|
+
break;
|
|
28
|
+
case 'clear':
|
|
29
|
+
await handleClear();
|
|
30
|
+
break;
|
|
31
|
+
case 'access':
|
|
32
|
+
case 'accessLevel':
|
|
33
|
+
await handleAccessLevel(value);
|
|
34
|
+
break;
|
|
35
|
+
case 'help':
|
|
36
|
+
showHelp();
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
plugins.logger.log('error', `Unknown command: ${command}`);
|
|
40
|
+
showHelp();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Interactive menu for config command
|
|
46
|
+
*/
|
|
47
|
+
async function handleInteractiveMenu(): Promise<void> {
|
|
48
|
+
console.log('');
|
|
49
|
+
console.log('╭─────────────────────────────────────────────────────────────╮');
|
|
50
|
+
console.log('│ gitzone config - Release Configuration │');
|
|
51
|
+
console.log('╰─────────────────────────────────────────────────────────────╯');
|
|
52
|
+
console.log('');
|
|
53
|
+
|
|
54
|
+
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
55
|
+
const response = await interactInstance.askQuestion({
|
|
56
|
+
type: 'list',
|
|
57
|
+
name: 'action',
|
|
58
|
+
message: 'What would you like to do?',
|
|
59
|
+
default: 'show',
|
|
60
|
+
choices: [
|
|
61
|
+
{ name: 'Show current configuration', value: 'show' },
|
|
62
|
+
{ name: 'Add a registry', value: 'add' },
|
|
63
|
+
{ name: 'Remove a registry', value: 'remove' },
|
|
64
|
+
{ name: 'Clear all registries', value: 'clear' },
|
|
65
|
+
{ name: 'Set access level (public/private)', value: 'access' },
|
|
66
|
+
{ name: 'Show help', value: 'help' },
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const action = (response as any).value;
|
|
71
|
+
|
|
72
|
+
switch (action) {
|
|
73
|
+
case 'show':
|
|
74
|
+
await handleShow();
|
|
75
|
+
break;
|
|
76
|
+
case 'add':
|
|
77
|
+
await handleAdd();
|
|
78
|
+
break;
|
|
79
|
+
case 'remove':
|
|
80
|
+
await handleRemove();
|
|
81
|
+
break;
|
|
82
|
+
case 'clear':
|
|
83
|
+
await handleClear();
|
|
84
|
+
break;
|
|
85
|
+
case 'access':
|
|
86
|
+
await handleAccessLevel();
|
|
87
|
+
break;
|
|
88
|
+
case 'help':
|
|
89
|
+
showHelp();
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Show current registry configuration
|
|
96
|
+
*/
|
|
97
|
+
async function handleShow(): Promise<void> {
|
|
98
|
+
const config = await ReleaseConfig.fromCwd();
|
|
99
|
+
const registries = config.getRegistries();
|
|
100
|
+
const accessLevel = config.getAccessLevel();
|
|
101
|
+
|
|
102
|
+
console.log('');
|
|
103
|
+
console.log('╭─────────────────────────────────────────────────────────────╮');
|
|
104
|
+
console.log('│ Release Configuration │');
|
|
105
|
+
console.log('╰─────────────────────────────────────────────────────────────╯');
|
|
106
|
+
console.log('');
|
|
107
|
+
|
|
108
|
+
// Show access level
|
|
109
|
+
plugins.logger.log('info', `Access Level: ${accessLevel}`);
|
|
110
|
+
console.log('');
|
|
111
|
+
|
|
112
|
+
if (registries.length === 0) {
|
|
113
|
+
plugins.logger.log('info', 'No release registries configured.');
|
|
114
|
+
console.log('');
|
|
115
|
+
console.log(' Run `gitzone config add <registry-url>` to add one.');
|
|
116
|
+
console.log('');
|
|
117
|
+
} else {
|
|
118
|
+
plugins.logger.log('info', `Configured registries (${registries.length}):`);
|
|
119
|
+
console.log('');
|
|
120
|
+
registries.forEach((url, index) => {
|
|
121
|
+
console.log(` ${index + 1}. ${url}`);
|
|
122
|
+
});
|
|
123
|
+
console.log('');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Add a registry URL
|
|
129
|
+
*/
|
|
130
|
+
async function handleAdd(url?: string): Promise<void> {
|
|
131
|
+
if (!url) {
|
|
132
|
+
// Interactive mode
|
|
133
|
+
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
134
|
+
const response = await interactInstance.askQuestion({
|
|
135
|
+
type: 'input',
|
|
136
|
+
name: 'registryUrl',
|
|
137
|
+
message: 'Enter registry URL:',
|
|
138
|
+
default: 'https://registry.npmjs.org',
|
|
139
|
+
validate: (input: string) => {
|
|
140
|
+
return !!(input && input.trim() !== '');
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
url = (response as any).value;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const config = await ReleaseConfig.fromCwd();
|
|
147
|
+
const added = config.addRegistry(url!);
|
|
148
|
+
|
|
149
|
+
if (added) {
|
|
150
|
+
await config.save();
|
|
151
|
+
plugins.logger.log('success', `Added registry: ${url}`);
|
|
152
|
+
} else {
|
|
153
|
+
plugins.logger.log('warn', `Registry already exists: ${url}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Remove a registry URL
|
|
159
|
+
*/
|
|
160
|
+
async function handleRemove(url?: string): Promise<void> {
|
|
161
|
+
const config = await ReleaseConfig.fromCwd();
|
|
162
|
+
const registries = config.getRegistries();
|
|
163
|
+
|
|
164
|
+
if (registries.length === 0) {
|
|
165
|
+
plugins.logger.log('warn', 'No registries configured to remove.');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!url) {
|
|
170
|
+
// Interactive mode - show list to select from
|
|
171
|
+
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
172
|
+
const response = await interactInstance.askQuestion({
|
|
173
|
+
type: 'list',
|
|
174
|
+
name: 'registryUrl',
|
|
175
|
+
message: 'Select registry to remove:',
|
|
176
|
+
choices: registries,
|
|
177
|
+
default: registries[0],
|
|
178
|
+
});
|
|
179
|
+
url = (response as any).value;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const removed = config.removeRegistry(url!);
|
|
183
|
+
|
|
184
|
+
if (removed) {
|
|
185
|
+
await config.save();
|
|
186
|
+
plugins.logger.log('success', `Removed registry: ${url}`);
|
|
187
|
+
} else {
|
|
188
|
+
plugins.logger.log('warn', `Registry not found: ${url}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Clear all registries
|
|
194
|
+
*/
|
|
195
|
+
async function handleClear(): Promise<void> {
|
|
196
|
+
const config = await ReleaseConfig.fromCwd();
|
|
197
|
+
|
|
198
|
+
if (!config.hasRegistries()) {
|
|
199
|
+
plugins.logger.log('info', 'No registries to clear.');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Confirm before clearing
|
|
204
|
+
const confirmed = await plugins.smartinteract.SmartInteract.getCliConfirmation(
|
|
205
|
+
'Clear all configured registries?',
|
|
206
|
+
false
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
if (confirmed) {
|
|
210
|
+
config.clearRegistries();
|
|
211
|
+
await config.save();
|
|
212
|
+
plugins.logger.log('success', 'All registries cleared.');
|
|
213
|
+
} else {
|
|
214
|
+
plugins.logger.log('info', 'Operation cancelled.');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Set or toggle access level
|
|
220
|
+
*/
|
|
221
|
+
async function handleAccessLevel(level?: string): Promise<void> {
|
|
222
|
+
const config = await ReleaseConfig.fromCwd();
|
|
223
|
+
const currentLevel = config.getAccessLevel();
|
|
224
|
+
|
|
225
|
+
if (!level) {
|
|
226
|
+
// Interactive mode - toggle or ask
|
|
227
|
+
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
228
|
+
const response = await interactInstance.askQuestion({
|
|
229
|
+
type: 'list',
|
|
230
|
+
name: 'accessLevel',
|
|
231
|
+
message: 'Select npm access level for publishing:',
|
|
232
|
+
choices: ['public', 'private'],
|
|
233
|
+
default: currentLevel,
|
|
234
|
+
});
|
|
235
|
+
level = (response as any).value;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Validate the level
|
|
239
|
+
if (level !== 'public' && level !== 'private') {
|
|
240
|
+
plugins.logger.log('error', `Invalid access level: ${level}. Must be 'public' or 'private'.`);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (level === currentLevel) {
|
|
245
|
+
plugins.logger.log('info', `Access level is already set to: ${level}`);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
config.setAccessLevel(level as 'public' | 'private');
|
|
250
|
+
await config.save();
|
|
251
|
+
plugins.logger.log('success', `Access level set to: ${level}`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Show help for config command
|
|
256
|
+
*/
|
|
257
|
+
function showHelp(): void {
|
|
258
|
+
console.log('');
|
|
259
|
+
console.log('Usage: gitzone config <command> [options]');
|
|
260
|
+
console.log('');
|
|
261
|
+
console.log('Commands:');
|
|
262
|
+
console.log(' show Display current release configuration');
|
|
263
|
+
console.log(' add [url] Add a registry URL');
|
|
264
|
+
console.log(' remove [url] Remove a registry URL');
|
|
265
|
+
console.log(' clear Clear all registries');
|
|
266
|
+
console.log(' access [public|private] Set npm access level for publishing');
|
|
267
|
+
console.log('');
|
|
268
|
+
console.log('Examples:');
|
|
269
|
+
console.log(' gitzone config show');
|
|
270
|
+
console.log(' gitzone config add https://registry.npmjs.org');
|
|
271
|
+
console.log(' gitzone config add https://verdaccio.example.com');
|
|
272
|
+
console.log(' gitzone config remove https://registry.npmjs.org');
|
|
273
|
+
console.log(' gitzone config clear');
|
|
274
|
+
console.log(' gitzone config access public');
|
|
275
|
+
console.log(' gitzone config access private');
|
|
276
|
+
console.log('');
|
|
277
|
+
}
|
|
@@ -3,6 +3,65 @@ import * as paths from '../paths.js';
|
|
|
3
3
|
import * as gulpFunction from '@push.rocks/gulp-function';
|
|
4
4
|
import { Project } from '../classes.project.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Migrates npmextra.json from old namespace keys to new package-scoped keys
|
|
8
|
+
*/
|
|
9
|
+
const migrateNamespaceKeys = (npmextraJson: any): boolean => {
|
|
10
|
+
let migrated = false;
|
|
11
|
+
const migrations = [
|
|
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
|
+
];
|
|
18
|
+
for (const { oldKey, newKey } of migrations) {
|
|
19
|
+
if (npmextraJson[oldKey] && !npmextraJson[newKey]) {
|
|
20
|
+
npmextraJson[newKey] = npmextraJson[oldKey];
|
|
21
|
+
delete npmextraJson[oldKey];
|
|
22
|
+
migrated = true;
|
|
23
|
+
console.log(`Migrated npmextra.json: ${oldKey} -> ${newKey}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return migrated;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Migrates npmAccessLevel from @ship.zone/szci to @git.zone/cli.release.accessLevel
|
|
31
|
+
* This is a one-time migration for projects using the old location
|
|
32
|
+
*/
|
|
33
|
+
const migrateAccessLevel = (npmextraJson: any): boolean => {
|
|
34
|
+
const szciConfig = npmextraJson['@ship.zone/szci'];
|
|
35
|
+
|
|
36
|
+
// Check if szci has npmAccessLevel that needs to be migrated
|
|
37
|
+
if (!szciConfig?.npmAccessLevel) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Check if we already have the new location
|
|
42
|
+
const gitzoneConfig = npmextraJson['@git.zone/cli'] || {};
|
|
43
|
+
if (gitzoneConfig?.release?.accessLevel) {
|
|
44
|
+
// Already migrated, just remove from szci
|
|
45
|
+
delete szciConfig.npmAccessLevel;
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Ensure @git.zone/cli and release exist
|
|
50
|
+
if (!npmextraJson['@git.zone/cli']) {
|
|
51
|
+
npmextraJson['@git.zone/cli'] = {};
|
|
52
|
+
}
|
|
53
|
+
if (!npmextraJson['@git.zone/cli'].release) {
|
|
54
|
+
npmextraJson['@git.zone/cli'].release = {};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Migrate the value
|
|
58
|
+
npmextraJson['@git.zone/cli'].release.accessLevel = szciConfig.npmAccessLevel;
|
|
59
|
+
delete szciConfig.npmAccessLevel;
|
|
60
|
+
|
|
61
|
+
console.log(`Migrated npmAccessLevel to @git.zone/cli.release.accessLevel`);
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
|
|
6
65
|
/**
|
|
7
66
|
* runs the npmextra file checking
|
|
8
67
|
*/
|
|
@@ -13,8 +72,14 @@ export const run = async (projectArg: Project) => {
|
|
|
13
72
|
const fileString = fileArg.contents.toString();
|
|
14
73
|
const npmextraJson = JSON.parse(fileString);
|
|
15
74
|
|
|
16
|
-
|
|
17
|
-
|
|
75
|
+
// Migrate old namespace keys to new package-scoped keys
|
|
76
|
+
migrateNamespaceKeys(npmextraJson);
|
|
77
|
+
|
|
78
|
+
// Migrate npmAccessLevel from szci to @git.zone/cli.release.accessLevel
|
|
79
|
+
migrateAccessLevel(npmextraJson);
|
|
80
|
+
|
|
81
|
+
if (!npmextraJson['@git.zone/cli']) {
|
|
82
|
+
npmextraJson['@git.zone/cli'] = {};
|
|
18
83
|
}
|
|
19
84
|
|
|
20
85
|
const expectedRepoInformation: string[] = [
|
|
@@ -31,7 +96,7 @@ export const run = async (projectArg: Project) => {
|
|
|
31
96
|
for (const expectedRepoInformationItem of expectedRepoInformation) {
|
|
32
97
|
if (
|
|
33
98
|
!plugins.smartobject.smartGet(
|
|
34
|
-
npmextraJson.
|
|
99
|
+
npmextraJson['@git.zone/cli'],
|
|
35
100
|
expectedRepoInformationItem,
|
|
36
101
|
)
|
|
37
102
|
) {
|
|
@@ -53,7 +118,7 @@ export const run = async (projectArg: Project) => {
|
|
|
53
118
|
);
|
|
54
119
|
if (cliProvidedValue) {
|
|
55
120
|
plugins.smartobject.smartAdd(
|
|
56
|
-
npmextraJson.
|
|
121
|
+
npmextraJson['@git.zone/cli'],
|
|
57
122
|
expectedRepoInformationItem,
|
|
58
123
|
cliProvidedValue,
|
|
59
124
|
);
|
|
@@ -63,8 +128,8 @@ export const run = async (projectArg: Project) => {
|
|
|
63
128
|
// delete obsolete
|
|
64
129
|
// tbd
|
|
65
130
|
|
|
66
|
-
if (!npmextraJson.
|
|
67
|
-
npmextraJson.
|
|
131
|
+
if (!npmextraJson['@ship.zone/szci']) {
|
|
132
|
+
npmextraJson['@ship.zone/szci'] = {};
|
|
68
133
|
}
|
|
69
134
|
|
|
70
135
|
fileArg.setContentsFromString(JSON.stringify(npmextraJson, null, 2));
|
|
@@ -74,7 +74,7 @@ export const run = async (projectArg: Project) => {
|
|
|
74
74
|
plugins.smartgulp.src([`package.json`]),
|
|
75
75
|
gulpFunction.forEach(async (fileArg: plugins.smartfile.SmartFile) => {
|
|
76
76
|
const npmextraConfig = new plugins.npmextra.Npmextra(paths.cwd);
|
|
77
|
-
const gitzoneData: any = npmextraConfig.dataFor('
|
|
77
|
+
const gitzoneData: any = npmextraConfig.dataFor('@git.zone/cli', {});
|
|
78
78
|
const fileString = fileArg.contents.toString();
|
|
79
79
|
const packageJson = JSON.parse(fileString);
|
|
80
80
|
|
package/ts/mod_format/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ export let run = async (
|
|
|
41
41
|
|
|
42
42
|
// Get configuration from npmextra
|
|
43
43
|
const npmextraConfig = new plugins.npmextra.Npmextra();
|
|
44
|
-
const formatConfig = npmextraConfig.dataFor<any>('
|
|
44
|
+
const formatConfig = npmextraConfig.dataFor<any>('@git.zone/cli.format', {
|
|
45
45
|
interactive: true,
|
|
46
46
|
showDiffs: false,
|
|
47
47
|
autoApprove: false,
|
|
@@ -43,7 +43,7 @@ export class ServiceManager {
|
|
|
43
43
|
*/
|
|
44
44
|
private async loadServiceConfiguration(): Promise<void> {
|
|
45
45
|
const npmextraConfig = new plugins.npmextra.Npmextra(process.cwd());
|
|
46
|
-
const gitzoneConfig = npmextraConfig.dataFor<any>('
|
|
46
|
+
const gitzoneConfig = npmextraConfig.dataFor<any>('@git.zone/cli', {});
|
|
47
47
|
|
|
48
48
|
// Check if services array exists
|
|
49
49
|
if (!gitzoneConfig.services || !Array.isArray(gitzoneConfig.services) || gitzoneConfig.services.length === 0) {
|
|
@@ -84,11 +84,11 @@ export class ServiceManager {
|
|
|
84
84
|
npmextraData = JSON.parse(content as string);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
// Update
|
|
88
|
-
if (!npmextraData.
|
|
89
|
-
npmextraData.
|
|
87
|
+
// Update @git.zone/cli.services
|
|
88
|
+
if (!npmextraData['@git.zone/cli']) {
|
|
89
|
+
npmextraData['@git.zone/cli'] = {};
|
|
90
90
|
}
|
|
91
|
-
npmextraData.
|
|
91
|
+
npmextraData['@git.zone/cli'].services = services;
|
|
92
92
|
|
|
93
93
|
// Write back to npmextra.json
|
|
94
94
|
await plugins.smartfs
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type TGitzoneProjectType = 'npm' | 'service' | 'wcc' | 'website';
|
|
2
|
-
/**
|
|
3
|
-
* type of the actual gitzone data
|
|
4
|
-
*/
|
|
5
|
-
export interface IGitzoneConfigData {
|
|
6
|
-
projectType: TGitzoneProjectType;
|
|
7
|
-
module: {
|
|
8
|
-
githost: string;
|
|
9
|
-
gitscope: string;
|
|
10
|
-
gitrepo: string;
|
|
11
|
-
description: string;
|
|
12
|
-
npmPackageName: string;
|
|
13
|
-
license: string;
|
|
14
|
-
projectDomain: string;
|
|
15
|
-
};
|
|
16
|
-
npmciOptions: {
|
|
17
|
-
npmAccessLevel: 'public' | 'private';
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* gitzone config
|
|
22
|
-
*/
|
|
23
|
-
export declare class GitzoneConfig {
|
|
24
|
-
static fromCwd(): Promise<GitzoneConfig>;
|
|
25
|
-
data: IGitzoneConfigData;
|
|
26
|
-
readConfigFromCwd(): Promise<void>;
|
|
27
|
-
constructor();
|
|
28
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as plugins from './gitzone.plugins.js';
|
|
2
|
-
import * as paths from './gitzone.paths.js';
|
|
3
|
-
/**
|
|
4
|
-
* gitzone config
|
|
5
|
-
*/
|
|
6
|
-
export class GitzoneConfig {
|
|
7
|
-
static async fromCwd() {
|
|
8
|
-
const gitzoneConfig = new GitzoneConfig();
|
|
9
|
-
await gitzoneConfig.readConfigFromCwd();
|
|
10
|
-
return gitzoneConfig;
|
|
11
|
-
}
|
|
12
|
-
async readConfigFromCwd() {
|
|
13
|
-
const npmextraInstance = new plugins.npmextra.Npmextra(paths.cwd);
|
|
14
|
-
this.data = npmextraInstance.dataFor('gitzone', {});
|
|
15
|
-
this.data.npmciOptions = npmextraInstance.dataFor('npmci', {
|
|
16
|
-
npmAccessLevel: 'public',
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
constructor() { }
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2l0em9uZS5jb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9naXR6b25lLmNvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLHNCQUFzQixDQUFDO0FBQ2hELE9BQU8sS0FBSyxLQUFLLE1BQU0sb0JBQW9CLENBQUM7QUF1QjVDOztHQUVHO0FBQ0gsTUFBTSxPQUFPLGFBQWE7SUFDakIsTUFBTSxDQUFDLEtBQUssQ0FBQyxPQUFPO1FBQ3pCLE1BQU0sYUFBYSxHQUFHLElBQUksYUFBYSxFQUFFLENBQUM7UUFDMUMsTUFBTSxhQUFhLENBQUMsaUJBQWlCLEVBQUUsQ0FBQztRQUN4QyxPQUFPLGFBQWEsQ0FBQztJQUN2QixDQUFDO0lBSU0sS0FBSyxDQUFDLGlCQUFpQjtRQUM1QixNQUFNLGdCQUFnQixHQUFHLElBQUksT0FBTyxDQUFDLFFBQVEsQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBQ2xFLElBQUksQ0FBQyxJQUFJLEdBQUcsZ0JBQWdCLENBQUMsT0FBTyxDQUFxQixTQUFTLEVBQUUsRUFBRSxDQUFDLENBQUM7UUFDeEUsSUFBSSxDQUFDLElBQUksQ0FBQyxZQUFZLEdBQUcsZ0JBQWdCLENBQUMsT0FBTyxDQUFxQyxPQUFPLEVBQUU7WUFDN0YsY0FBYyxFQUFFLFFBQVE7U0FDekIsQ0FBQyxDQUFDO0lBQ0wsQ0FBQztJQUVELGdCQUFlLENBQUM7Q0FDakIifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist_ts/gitzone.paths.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as plugins from './gitzone.plugins.js';
|
|
2
|
-
export let packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
|
3
|
-
export let assetsDir = plugins.path.join(packageDir, './assets');
|
|
4
|
-
export let templatesDir = plugins.path.join(assetsDir, 'templates');
|
|
5
|
-
export let cwd = process.cwd();
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2l0em9uZS5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2dpdHpvbmUucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxzQkFBc0IsQ0FBQztBQUVoRCxNQUFNLENBQUMsSUFBSSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQ3ZDLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLHdCQUF3QixDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQy9ELEtBQUssQ0FDTixDQUFDO0FBQ0YsTUFBTSxDQUFDLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxVQUFVLENBQUMsQ0FBQztBQUNqRSxNQUFNLENBQUMsSUFBSSxZQUFZLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLFdBQVcsQ0FBQyxDQUFDO0FBQ3BFLE1BQU0sQ0FBQyxJQUFJLEdBQUcsR0FBRyxPQUFPLENBQUMsR0FBRyxFQUFFLENBQUMifQ==
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as smartlog from '@push.rocks/smartlog';
|
|
2
|
-
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
|
3
|
-
import * as npmextra from '@push.rocks/npmextra';
|
|
4
|
-
import * as path from 'path';
|
|
5
|
-
import * as projectinfo from '@push.rocks/projectinfo';
|
|
6
|
-
import * as smartcli from '@push.rocks/smartcli';
|
|
7
|
-
import * as smartpath from '@push.rocks/smartpath';
|
|
8
|
-
import * as smartpromise from '@push.rocks/smartpromise';
|
|
9
|
-
import * as smartupdate from '@push.rocks/smartupdate';
|
|
10
|
-
export { smartlog, smartlogDestinationLocal, npmextra, path, projectinfo, smartcli, smartpath, smartpromise, smartupdate, };
|