@git.zone/cli 1.16.7 → 1.16.9
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 +1 -1
- package/dist_ts/mod_format/classes.baseformatter.d.ts +0 -2
- package/dist_ts/mod_format/classes.baseformatter.js +14 -23
- package/dist_ts/mod_format/classes.changecache.js +14 -29
- package/dist_ts/mod_format/classes.dependency-analyzer.js +24 -18
- package/dist_ts/mod_format/classes.diffreporter.js +4 -4
- package/dist_ts/mod_format/classes.formatcontext.d.ts +0 -13
- package/dist_ts/mod_format/classes.formatcontext.js +1 -41
- package/dist_ts/mod_format/classes.formatplanner.js +25 -45
- package/dist_ts/mod_format/classes.formatstats.js +22 -20
- package/dist_ts/mod_format/classes.rollbackmanager.js +20 -32
- package/dist_ts/mod_format/format.cleanup.js +7 -2
- package/dist_ts/mod_format/format.copy.d.ts +1 -1
- package/dist_ts/mod_format/format.copy.js +3 -3
- package/dist_ts/mod_format/format.gitignore.js +27 -7
- package/dist_ts/mod_format/format.license.js +1 -1
- package/dist_ts/mod_format/format.npmextra.js +1 -1
- package/dist_ts/mod_format/format.packagejson.js +5 -3
- package/dist_ts/mod_format/format.prettier.js +7 -2
- package/dist_ts/mod_format/format.readme.js +1 -1
- package/dist_ts/mod_format/format.templates.js +1 -1
- package/dist_ts/mod_format/format.tsconfig.js +4 -2
- package/dist_ts/mod_format/formatters/cleanup.formatter.js +8 -3
- package/dist_ts/mod_format/formatters/legacy.formatter.js +6 -4
- package/dist_ts/mod_format/formatters/prettier.formatter.js +68 -51
- package/dist_ts/mod_format/formatters/readme.formatter.js +6 -4
- package/dist_ts/mod_format/index.js +13 -71
- package/dist_ts/mod_meta/meta.classes.meta.js +1 -1
- package/dist_ts/mod_standard/index.js +1 -1
- package/dist_ts/mod_start/index.js +1 -1
- package/dist_ts/mod_template/index.js +1 -1
- package/npmextra.json +1 -1
- package/package.json +1 -1
- package/readme.hints.md +8 -3
- package/readme.md +30 -3
- package/readme.plan.md +21 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/mod_format/classes.baseformatter.ts +28 -39
- package/ts/mod_format/classes.changecache.ts +74 -80
- package/ts/mod_format/classes.dependency-analyzer.ts +46 -36
- package/ts/mod_format/classes.diffreporter.ts +44 -28
- package/ts/mod_format/classes.formatcontext.ts +3 -54
- package/ts/mod_format/classes.formatplanner.ts +56 -70
- package/ts/mod_format/classes.formatstats.ts +69 -49
- package/ts/mod_format/classes.rollbackmanager.ts +123 -103
- package/ts/mod_format/format.cleanup.ts +9 -2
- package/ts/mod_format/format.copy.ts +17 -14
- package/ts/mod_format/format.gitignore.ts +33 -7
- package/ts/mod_format/format.license.ts +3 -1
- package/ts/mod_format/format.npmextra.ts +9 -2
- package/ts/mod_format/format.packagejson.ts +47 -12
- package/ts/mod_format/format.prettier.ts +10 -2
- package/ts/mod_format/format.readme.ts +2 -1
- package/ts/mod_format/format.templates.ts +15 -7
- package/ts/mod_format/format.tsconfig.ts +6 -2
- package/ts/mod_format/formatters/cleanup.formatter.ts +13 -8
- package/ts/mod_format/formatters/copy.formatter.ts +1 -1
- package/ts/mod_format/formatters/gitignore.formatter.ts +1 -1
- package/ts/mod_format/formatters/legacy.formatter.ts +19 -12
- package/ts/mod_format/formatters/license.formatter.ts +1 -1
- package/ts/mod_format/formatters/npmextra.formatter.ts +1 -1
- package/ts/mod_format/formatters/packagejson.formatter.ts +1 -1
- package/ts/mod_format/formatters/prettier.formatter.ts +114 -78
- package/ts/mod_format/formatters/readme.formatter.ts +11 -9
- package/ts/mod_format/formatters/templates.formatter.ts +1 -1
- package/ts/mod_format/formatters/tsconfig.formatter.ts +1 -1
- package/ts/mod_format/index.ts +57 -113
- package/ts/mod_format/interfaces.format.ts +3 -3
- package/ts/mod_meta/meta.classes.meta.ts +57 -19
- package/ts/mod_standard/index.ts +3 -1
- package/ts/mod_start/index.ts +3 -1
- package/ts/mod_template/index.ts +5 -2
package/ts/mod_format/index.ts
CHANGED
|
@@ -16,27 +16,29 @@ import { PrettierFormatter } from './formatters/prettier.formatter.js';
|
|
|
16
16
|
import { ReadmeFormatter } from './formatters/readme.formatter.js';
|
|
17
17
|
import { CopyFormatter } from './formatters/copy.formatter.js';
|
|
18
18
|
|
|
19
|
-
export let run = async (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
export let run = async (
|
|
20
|
+
options: {
|
|
21
|
+
dryRun?: boolean;
|
|
22
|
+
yes?: boolean;
|
|
23
|
+
planOnly?: boolean;
|
|
24
|
+
savePlan?: string;
|
|
25
|
+
fromPlan?: string;
|
|
26
|
+
detailed?: boolean;
|
|
27
|
+
interactive?: boolean;
|
|
28
|
+
parallel?: boolean;
|
|
29
|
+
verbose?: boolean;
|
|
30
|
+
} = {},
|
|
31
|
+
): Promise<any> => {
|
|
30
32
|
// Set verbose mode if requested
|
|
31
33
|
if (options.verbose) {
|
|
32
34
|
setVerboseMode(true);
|
|
33
35
|
}
|
|
34
|
-
|
|
36
|
+
|
|
35
37
|
const project = await Project.fromCwd();
|
|
36
38
|
const context = new FormatContext();
|
|
37
|
-
|
|
39
|
+
// Cache system removed - no longer needed
|
|
38
40
|
const planner = new FormatPlanner();
|
|
39
|
-
|
|
41
|
+
|
|
40
42
|
// Get configuration from npmextra
|
|
41
43
|
const npmextraConfig = new plugins.npmextra.Npmextra();
|
|
42
44
|
const formatConfig = npmextraConfig.dataFor<any>('gitzone.format', {
|
|
@@ -49,30 +51,27 @@ export let run = async (options: {
|
|
|
49
51
|
autoRollbackOnError: true,
|
|
50
52
|
backupRetentionDays: 7,
|
|
51
53
|
maxBackupSize: '100MB',
|
|
52
|
-
excludePatterns: ['node_modules/**', '.git/**']
|
|
54
|
+
excludePatterns: ['node_modules/**', '.git/**'],
|
|
53
55
|
},
|
|
54
56
|
modules: {
|
|
55
57
|
skip: [],
|
|
56
58
|
only: [],
|
|
57
|
-
order: []
|
|
59
|
+
order: [],
|
|
58
60
|
},
|
|
59
61
|
parallel: true,
|
|
60
62
|
cache: {
|
|
61
63
|
enabled: true,
|
|
62
|
-
clean: true
|
|
63
|
-
}
|
|
64
|
+
clean: true, // Clean invalid entries from cache
|
|
65
|
+
},
|
|
64
66
|
});
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
await context.getChangeCache().clean();
|
|
69
|
-
}
|
|
70
|
-
|
|
67
|
+
|
|
68
|
+
// Cache cleaning removed - no longer using cache system
|
|
69
|
+
|
|
71
70
|
// Override config with command options
|
|
72
71
|
const interactive = options.interactive ?? formatConfig.interactive;
|
|
73
72
|
const autoApprove = options.yes ?? formatConfig.autoApprove;
|
|
74
73
|
const parallel = options.parallel ?? formatConfig.parallel;
|
|
75
|
-
|
|
74
|
+
|
|
76
75
|
try {
|
|
77
76
|
// Initialize formatters
|
|
78
77
|
const formatters = [
|
|
@@ -87,9 +86,9 @@ export let run = async (options: {
|
|
|
87
86
|
new ReadmeFormatter(context, project),
|
|
88
87
|
new CopyFormatter(context, project),
|
|
89
88
|
];
|
|
90
|
-
|
|
89
|
+
|
|
91
90
|
// Filter formatters based on configuration
|
|
92
|
-
const activeFormatters = formatters.filter(formatter => {
|
|
91
|
+
const activeFormatters = formatters.filter((formatter) => {
|
|
93
92
|
if (formatConfig.modules.only.length > 0) {
|
|
94
93
|
return formatConfig.modules.only.includes(formatter.name);
|
|
95
94
|
}
|
|
@@ -98,33 +97,36 @@ export let run = async (options: {
|
|
|
98
97
|
}
|
|
99
98
|
return true;
|
|
100
99
|
});
|
|
101
|
-
|
|
100
|
+
|
|
102
101
|
// Plan phase
|
|
103
102
|
logger.log('info', 'Analyzing project for format operations...');
|
|
104
103
|
let plan = options.fromPlan
|
|
105
104
|
? JSON.parse(await plugins.smartfile.fs.toStringSync(options.fromPlan))
|
|
106
105
|
: await planner.planFormat(activeFormatters);
|
|
107
|
-
|
|
106
|
+
|
|
108
107
|
// Display plan
|
|
109
108
|
await planner.displayPlan(plan, options.detailed);
|
|
110
|
-
|
|
109
|
+
|
|
111
110
|
// Save plan if requested
|
|
112
111
|
if (options.savePlan) {
|
|
113
|
-
await plugins.smartfile.memory.toFs(
|
|
112
|
+
await plugins.smartfile.memory.toFs(
|
|
113
|
+
JSON.stringify(plan, null, 2),
|
|
114
|
+
options.savePlan,
|
|
115
|
+
);
|
|
114
116
|
logger.log('info', `Plan saved to ${options.savePlan}`);
|
|
115
117
|
}
|
|
116
|
-
|
|
118
|
+
|
|
117
119
|
// Exit if plan-only mode
|
|
118
120
|
if (options.planOnly) {
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
|
-
|
|
123
|
+
|
|
122
124
|
// Dry-run mode
|
|
123
125
|
if (options.dryRun) {
|
|
124
126
|
logger.log('info', 'Dry-run mode - no changes will be made');
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
|
-
|
|
129
|
+
|
|
128
130
|
// Interactive confirmation
|
|
129
131
|
if (interactive && !autoApprove) {
|
|
130
132
|
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
@@ -132,117 +134,59 @@ export let run = async (options: {
|
|
|
132
134
|
type: 'confirm',
|
|
133
135
|
name: 'proceed',
|
|
134
136
|
message: 'Proceed with formatting?',
|
|
135
|
-
default: true
|
|
137
|
+
default: true,
|
|
136
138
|
});
|
|
137
|
-
|
|
139
|
+
|
|
138
140
|
if (!(response as any).value) {
|
|
139
141
|
logger.log('info', 'Format operation cancelled by user');
|
|
140
142
|
return;
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
|
-
|
|
145
|
+
|
|
144
146
|
// Execute phase
|
|
145
|
-
logger.log(
|
|
147
|
+
logger.log(
|
|
148
|
+
'info',
|
|
149
|
+
`Executing format operations${parallel ? ' in parallel' : ' sequentially'}...`,
|
|
150
|
+
);
|
|
146
151
|
await planner.executePlan(plan, activeFormatters, context, parallel);
|
|
147
|
-
|
|
152
|
+
|
|
148
153
|
// Finish statistics tracking
|
|
149
154
|
context.getFormatStats().finish();
|
|
150
|
-
|
|
155
|
+
|
|
151
156
|
// Display statistics
|
|
152
157
|
const showStats = npmextraConfig.dataFor('gitzone.format.showStats', true);
|
|
153
158
|
if (showStats) {
|
|
154
159
|
context.getFormatStats().displayStats();
|
|
155
160
|
}
|
|
156
|
-
|
|
161
|
+
|
|
157
162
|
// Save stats if requested
|
|
158
163
|
if (options.detailed) {
|
|
159
164
|
const statsPath = `.nogit/format-stats-${Date.now()}.json`;
|
|
160
165
|
await context.getFormatStats().saveReport(statsPath);
|
|
161
166
|
}
|
|
162
|
-
|
|
167
|
+
|
|
163
168
|
logger.log('success', 'Format operations completed successfully!');
|
|
164
|
-
|
|
165
169
|
} catch (error) {
|
|
166
170
|
logger.log('error', `Format operation failed: ${error.message}`);
|
|
167
|
-
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
logger.log('info', 'Attempting automatic rollback...');
|
|
171
|
-
try {
|
|
172
|
-
await context.rollbackOperation();
|
|
173
|
-
logger.log('success', 'Rollback completed successfully');
|
|
174
|
-
} catch (rollbackError) {
|
|
175
|
-
logger.log('error', `Rollback failed: ${rollbackError.message}`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
171
|
+
|
|
172
|
+
// Rollback system has been removed for stability
|
|
173
|
+
|
|
179
174
|
throw error;
|
|
180
175
|
}
|
|
181
176
|
};
|
|
182
177
|
|
|
183
178
|
// Export CLI command handlers
|
|
184
179
|
export const handleRollback = async (operationId?: string): Promise<void> => {
|
|
185
|
-
|
|
186
|
-
const rollbackManager = context.getRollbackManager();
|
|
187
|
-
|
|
188
|
-
if (!operationId) {
|
|
189
|
-
// Rollback to last operation
|
|
190
|
-
const backups = await rollbackManager.listBackups();
|
|
191
|
-
const lastOperation = backups
|
|
192
|
-
.filter(op => op.status !== 'rolled-back')
|
|
193
|
-
.sort((a, b) => b.timestamp - a.timestamp)[0];
|
|
194
|
-
|
|
195
|
-
if (!lastOperation) {
|
|
196
|
-
logger.log('warn', 'No operations available for rollback');
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
operationId = lastOperation.id;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
try {
|
|
204
|
-
await rollbackManager.rollback(operationId);
|
|
205
|
-
logger.log('success', `Successfully rolled back operation ${operationId}`);
|
|
206
|
-
} catch (error) {
|
|
207
|
-
logger.log('error', `Rollback failed: ${error.message}`);
|
|
208
|
-
throw error;
|
|
209
|
-
}
|
|
180
|
+
logger.log('info', 'Rollback system has been disabled for stability');
|
|
210
181
|
};
|
|
211
182
|
|
|
212
183
|
export const handleListBackups = async (): Promise<void> => {
|
|
213
|
-
|
|
214
|
-
const rollbackManager = context.getRollbackManager();
|
|
215
|
-
const backups = await rollbackManager.listBackups();
|
|
216
|
-
|
|
217
|
-
if (backups.length === 0) {
|
|
218
|
-
logger.log('info', 'No backup operations found');
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
console.log('\nAvailable backups:');
|
|
223
|
-
console.log('━'.repeat(50));
|
|
224
|
-
|
|
225
|
-
for (const backup of backups) {
|
|
226
|
-
const date = new Date(backup.timestamp).toLocaleString();
|
|
227
|
-
const status = backup.status;
|
|
228
|
-
const filesCount = backup.files.length;
|
|
229
|
-
|
|
230
|
-
console.log(`ID: ${backup.id}`);
|
|
231
|
-
console.log(`Date: ${date}`);
|
|
232
|
-
console.log(`Status: ${status}`);
|
|
233
|
-
console.log(`Files: ${filesCount}`);
|
|
234
|
-
console.log('─'.repeat(50));
|
|
235
|
-
}
|
|
184
|
+
logger.log('info', 'Backup system has been disabled for stability');
|
|
236
185
|
};
|
|
237
186
|
|
|
238
187
|
export const handleCleanBackups = async (): Promise<void> => {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const retentionDays = npmextraConfig.dataFor<any>('gitzone.format.rollback.backupRetentionDays', 7);
|
|
245
|
-
|
|
246
|
-
await rollbackManager.cleanOldBackups(retentionDays);
|
|
247
|
-
logger.log('success', `Cleaned backups older than ${retentionDays} days`);
|
|
248
|
-
};
|
|
188
|
+
logger.log(
|
|
189
|
+
'info',
|
|
190
|
+
'Backup cleaning has been disabled - backup system removed',
|
|
191
|
+
);
|
|
192
|
+
};
|
|
@@ -9,7 +9,7 @@ export type IFormatOperation = {
|
|
|
9
9
|
}>;
|
|
10
10
|
status: 'pending' | 'in-progress' | 'completed' | 'failed' | 'rolled-back';
|
|
11
11
|
error?: Error;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
|
|
14
14
|
export type IFormatPlan = {
|
|
15
15
|
summary: {
|
|
@@ -32,7 +32,7 @@ export type IFormatPlan = {
|
|
|
32
32
|
message: string;
|
|
33
33
|
module: string;
|
|
34
34
|
}>;
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
export type IPlannedChange = {
|
|
38
38
|
type: 'create' | 'modify' | 'delete';
|
|
@@ -42,4 +42,4 @@ export type IPlannedChange = {
|
|
|
42
42
|
content?: string; // For create/modify operations
|
|
43
43
|
diff?: string;
|
|
44
44
|
size?: number;
|
|
45
|
-
}
|
|
45
|
+
};
|
|
@@ -35,7 +35,10 @@ export class Meta {
|
|
|
35
35
|
* sorts the metaRepoData
|
|
36
36
|
*/
|
|
37
37
|
public async sortMetaRepoData() {
|
|
38
|
-
const stringifiedMetadata = plugins.smartjson.stringify(
|
|
38
|
+
const stringifiedMetadata = plugins.smartjson.stringify(
|
|
39
|
+
this.metaRepoData,
|
|
40
|
+
[],
|
|
41
|
+
);
|
|
39
42
|
this.metaRepoData = plugins.smartjson.parse(stringifiedMetadata);
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -45,11 +48,15 @@ export class Meta {
|
|
|
45
48
|
public async readDirectory() {
|
|
46
49
|
await this.syncToRemote(true);
|
|
47
50
|
logger.log('info', `reading directory`);
|
|
48
|
-
const metaFileExists = plugins.smartfile.fs.fileExistsSync(
|
|
51
|
+
const metaFileExists = plugins.smartfile.fs.fileExistsSync(
|
|
52
|
+
this.filePaths.metaJson,
|
|
53
|
+
);
|
|
49
54
|
if (!metaFileExists) {
|
|
50
55
|
throw new Error(`meta file does not exist at ${this.filePaths.metaJson}`);
|
|
51
56
|
}
|
|
52
|
-
this.metaRepoData = plugins.smartfile.fs.toObjectSync(
|
|
57
|
+
this.metaRepoData = plugins.smartfile.fs.toObjectSync(
|
|
58
|
+
this.filePaths.metaJson,
|
|
59
|
+
);
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
/**
|
|
@@ -76,7 +83,10 @@ export class Meta {
|
|
|
76
83
|
this.filePaths.metaJson,
|
|
77
84
|
);
|
|
78
85
|
// write .gitignore to disk
|
|
79
|
-
plugins.smartfile.memory.toFsSync(
|
|
86
|
+
plugins.smartfile.memory.toFsSync(
|
|
87
|
+
await this.generateGitignore(),
|
|
88
|
+
this.filePaths.gitIgnore,
|
|
89
|
+
);
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
/**
|
|
@@ -84,13 +94,17 @@ export class Meta {
|
|
|
84
94
|
*/
|
|
85
95
|
public async syncToRemote(gitCleanArg = false) {
|
|
86
96
|
logger.log('info', `syncing from origin master`);
|
|
87
|
-
await this.smartshellInstance.exec(
|
|
97
|
+
await this.smartshellInstance.exec(
|
|
98
|
+
`cd ${this.cwd} && git pull origin master`,
|
|
99
|
+
);
|
|
88
100
|
if (gitCleanArg) {
|
|
89
101
|
logger.log('info', `cleaning the repository from old directories`);
|
|
90
102
|
await this.smartshellInstance.exec(`cd ${this.cwd} && git clean -fd`);
|
|
91
103
|
}
|
|
92
104
|
logger.log('info', `syncing to remote origin master`);
|
|
93
|
-
await this.smartshellInstance.exec(
|
|
105
|
+
await this.smartshellInstance.exec(
|
|
106
|
+
`cd ${this.cwd} && git push origin master`,
|
|
107
|
+
);
|
|
94
108
|
}
|
|
95
109
|
|
|
96
110
|
/**
|
|
@@ -98,7 +112,9 @@ export class Meta {
|
|
|
98
112
|
*/
|
|
99
113
|
public async updateLocalRepos() {
|
|
100
114
|
await this.syncToRemote();
|
|
101
|
-
const projects = plugins.smartfile.fs.toObjectSync(
|
|
115
|
+
const projects = plugins.smartfile.fs.toObjectSync(
|
|
116
|
+
this.filePaths.metaJson,
|
|
117
|
+
).projects;
|
|
102
118
|
const preExistingFolders = plugins.smartfile.fs.listFoldersSync(this.cwd);
|
|
103
119
|
for (const preExistingFolderArg of preExistingFolders) {
|
|
104
120
|
if (
|
|
@@ -107,14 +123,18 @@ export class Meta {
|
|
|
107
123
|
projectFolder.startsWith(preExistingFolderArg),
|
|
108
124
|
)
|
|
109
125
|
) {
|
|
110
|
-
const response =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
126
|
+
const response =
|
|
127
|
+
await plugins.smartinteraction.SmartInteract.getCliConfirmation(
|
|
128
|
+
`Do you want to delete superfluous directory >>${preExistingFolderArg}<< ?`,
|
|
129
|
+
true,
|
|
130
|
+
);
|
|
114
131
|
if (response) {
|
|
115
132
|
logger.log('warn', `Deleting >>${preExistingFolderArg}<<!`);
|
|
116
133
|
} else {
|
|
117
|
-
logger.log(
|
|
134
|
+
logger.log(
|
|
135
|
+
'warn',
|
|
136
|
+
`Not deleting ${preExistingFolderArg} by request!`,
|
|
137
|
+
);
|
|
118
138
|
}
|
|
119
139
|
}
|
|
120
140
|
}
|
|
@@ -160,7 +180,9 @@ export class Meta {
|
|
|
160
180
|
*/
|
|
161
181
|
public async initProject() {
|
|
162
182
|
await this.syncToRemote(true);
|
|
163
|
-
const fileExists = await plugins.smartfile.fs.fileExists(
|
|
183
|
+
const fileExists = await plugins.smartfile.fs.fileExists(
|
|
184
|
+
this.filePaths.metaJson,
|
|
185
|
+
);
|
|
164
186
|
if (!fileExists) {
|
|
165
187
|
await plugins.smartfile.memory.toFs(
|
|
166
188
|
JSON.stringify({
|
|
@@ -168,7 +190,10 @@ export class Meta {
|
|
|
168
190
|
}),
|
|
169
191
|
this.filePaths.metaJson,
|
|
170
192
|
);
|
|
171
|
-
logger.log(
|
|
193
|
+
logger.log(
|
|
194
|
+
`success`,
|
|
195
|
+
`created a new .meta.json in directory ${this.cwd}`,
|
|
196
|
+
);
|
|
172
197
|
await plugins.smartfile.memory.toFs(
|
|
173
198
|
JSON.stringify({
|
|
174
199
|
name: this.dirName,
|
|
@@ -176,9 +201,15 @@ export class Meta {
|
|
|
176
201
|
}),
|
|
177
202
|
this.filePaths.packageJson,
|
|
178
203
|
);
|
|
179
|
-
logger.log(
|
|
204
|
+
logger.log(
|
|
205
|
+
`success`,
|
|
206
|
+
`created a new package.json in directory ${this.cwd}`,
|
|
207
|
+
);
|
|
180
208
|
} else {
|
|
181
|
-
logger.log(
|
|
209
|
+
logger.log(
|
|
210
|
+
`error`,
|
|
211
|
+
`directory ${this.cwd} already has a .metaJson file. Doing nothing.`,
|
|
212
|
+
);
|
|
182
213
|
}
|
|
183
214
|
await this.smartshellInstance.exec(
|
|
184
215
|
`cd ${this.cwd} && git add -A && git commit -m "feat(project): init meta project for ${this.dirName}"`,
|
|
@@ -195,7 +226,9 @@ export class Meta {
|
|
|
195
226
|
const existingProject = this.metaRepoData.projects[projectNameArg];
|
|
196
227
|
|
|
197
228
|
if (existingProject) {
|
|
198
|
-
throw new Error(
|
|
229
|
+
throw new Error(
|
|
230
|
+
'Project already exists! Please remove it first before adding it again.',
|
|
231
|
+
);
|
|
199
232
|
}
|
|
200
233
|
|
|
201
234
|
this.metaRepoData.projects[projectNameArg] = gitUrlArg;
|
|
@@ -217,7 +250,10 @@ export class Meta {
|
|
|
217
250
|
const existingProject = this.metaRepoData.projects[projectNameArg];
|
|
218
251
|
|
|
219
252
|
if (!existingProject) {
|
|
220
|
-
logger.log(
|
|
253
|
+
logger.log(
|
|
254
|
+
'error',
|
|
255
|
+
`Project ${projectNameArg} does not exist! So it cannot be removed`,
|
|
256
|
+
);
|
|
221
257
|
return;
|
|
222
258
|
}
|
|
223
259
|
|
|
@@ -228,7 +264,9 @@ export class Meta {
|
|
|
228
264
|
await this.writeToDisk();
|
|
229
265
|
|
|
230
266
|
logger.log('info', 'removing directory from cwd');
|
|
231
|
-
await plugins.smartfile.fs.remove(
|
|
267
|
+
await plugins.smartfile.fs.remove(
|
|
268
|
+
plugins.path.join(paths.cwd, projectNameArg),
|
|
269
|
+
);
|
|
232
270
|
await this.updateLocalRepos();
|
|
233
271
|
}
|
|
234
272
|
}
|
package/ts/mod_standard/index.ts
CHANGED
|
@@ -16,7 +16,9 @@ export let run = () => {
|
|
|
16
16
|
* create a new project with 'gitzone template [template]'
|
|
17
17
|
the following templates exist: ${(() => {
|
|
18
18
|
let projects = `\n`;
|
|
19
|
-
for (const template of plugins.smartfile.fs.listFoldersSync(
|
|
19
|
+
for (const template of plugins.smartfile.fs.listFoldersSync(
|
|
20
|
+
paths.templatesDir,
|
|
21
|
+
)) {
|
|
20
22
|
projects += ` - ${template}\n`;
|
|
21
23
|
}
|
|
22
24
|
return projects;
|
package/ts/mod_start/index.ts
CHANGED
|
@@ -15,7 +15,9 @@ export const run = async (argvArg: any) => {
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
await smartshellInstance.execStrict(`cd ${paths.cwd} && git checkout master`);
|
|
18
|
-
await smartshellInstance.execStrict(
|
|
18
|
+
await smartshellInstance.execStrict(
|
|
19
|
+
`cd ${paths.cwd} && git pull origin master`,
|
|
20
|
+
);
|
|
19
21
|
await smartshellInstance.execStrict(`cd ${paths.cwd} && npm ci`);
|
|
20
22
|
|
|
21
23
|
await provideNoGitFiles();
|
package/ts/mod_template/index.ts
CHANGED
|
@@ -16,7 +16,9 @@ export const isTemplate = async (templateNameArg: string) => {
|
|
|
16
16
|
|
|
17
17
|
export const getTemplate = async (templateNameArg: string) => {
|
|
18
18
|
if (isTemplate(templateNameArg)) {
|
|
19
|
-
const localScafTemplate = new plugins.smartscaf.ScafTemplate(
|
|
19
|
+
const localScafTemplate = new plugins.smartscaf.ScafTemplate(
|
|
20
|
+
getTemplatePath(templateNameArg),
|
|
21
|
+
);
|
|
20
22
|
await localScafTemplate.readTemplateFromDir();
|
|
21
23
|
return localScafTemplate;
|
|
22
24
|
} else {
|
|
@@ -32,7 +34,8 @@ export const run = async (argvArg: any) => {
|
|
|
32
34
|
const answerBucket = await smartinteract.askQuestion({
|
|
33
35
|
type: 'list',
|
|
34
36
|
default: 'npm',
|
|
35
|
-
message:
|
|
37
|
+
message:
|
|
38
|
+
'What template do you want to scaffold? (Only showing mpost common options)',
|
|
36
39
|
name: 'templateName',
|
|
37
40
|
choices: ['npm', 'service', 'wcc', 'website'],
|
|
38
41
|
});
|