@git.zone/cli 1.21.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/mod_commit/index.js +5 -2
- package/dist_ts/mod_commit/mod.helpers.js +24 -9
- package/dist_ts/mod_format/classes.baseformatter.js +4 -4
- package/dist_ts/mod_format/classes.changecache.js +29 -17
- package/dist_ts/mod_format/classes.diffreporter.js +10 -4
- package/dist_ts/mod_format/classes.formatstats.js +5 -2
- package/dist_ts/mod_format/classes.rollbackmanager.js +41 -17
- package/dist_ts/mod_format/format.cleanup.js +5 -3
- package/dist_ts/mod_format/format.copy.js +12 -4
- package/dist_ts/mod_format/format.gitignore.js +14 -5
- package/dist_ts/mod_format/format.license.js +4 -2
- package/dist_ts/mod_format/format.packagejson.js +6 -2
- package/dist_ts/mod_format/format.readme.js +9 -5
- package/dist_ts/mod_format/format.tsconfig.js +7 -4
- package/dist_ts/mod_format/formatters/cleanup.formatter.js +2 -2
- package/dist_ts/mod_format/formatters/prettier.formatter.js +19 -6
- package/dist_ts/mod_format/index.js +9 -3
- package/dist_ts/mod_meta/meta.classes.meta.js +82 -17
- package/dist_ts/mod_services/classes.serviceconfiguration.d.ts +7 -0
- package/dist_ts/mod_services/classes.serviceconfiguration.js +86 -10
- package/dist_ts/mod_services/classes.servicemanager.d.ts +33 -0
- package/dist_ts/mod_services/classes.servicemanager.js +319 -10
- package/dist_ts/mod_services/helpers.d.ts +1 -1
- package/dist_ts/mod_services/helpers.js +8 -4
- package/dist_ts/mod_services/index.js +51 -27
- package/dist_ts/mod_standard/index.js +22 -9
- package/dist_ts/mod_template/index.js +2 -2
- package/dist_ts/plugins.d.ts +2 -0
- package/dist_ts/plugins.js +4 -1
- package/package.json +7 -6
- package/readme.hints.md +55 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/mod_commit/index.ts +4 -4
- package/ts/mod_commit/mod.helpers.ts +23 -11
- package/ts/mod_format/classes.baseformatter.ts +3 -3
- package/ts/mod_format/classes.changecache.ts +28 -16
- package/ts/mod_format/classes.diffreporter.ts +9 -8
- package/ts/mod_format/classes.formatstats.ts +4 -4
- package/ts/mod_format/classes.rollbackmanager.ts +40 -18
- package/ts/mod_format/format.cleanup.ts +4 -4
- package/ts/mod_format/format.copy.ts +11 -3
- package/ts/mod_format/format.gitignore.ts +13 -6
- package/ts/mod_format/format.license.ts +3 -3
- package/ts/mod_format/format.packagejson.ts +5 -3
- package/ts/mod_format/format.readme.ts +8 -11
- package/ts/mod_format/format.tsconfig.ts +6 -5
- package/ts/mod_format/formatters/cleanup.formatter.ts +1 -1
- package/ts/mod_format/formatters/prettier.formatter.ts +18 -8
- package/ts/mod_format/index.ts +10 -5
- package/ts/mod_meta/meta.classes.meta.ts +84 -41
- package/ts/mod_services/classes.serviceconfiguration.ts +121 -35
- package/ts/mod_services/classes.servicemanager.ts +365 -32
- package/ts/mod_services/helpers.ts +8 -4
- package/ts/mod_services/index.ts +73 -45
- package/ts/mod_standard/index.ts +23 -10
- package/ts/mod_template/index.ts +1 -1
- package/ts/plugins.ts +4 -0
|
@@ -21,14 +21,15 @@ export class DiffReporter {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
try {
|
|
24
|
-
const exists = await plugins.
|
|
24
|
+
const exists = await plugins.smartfs.file(change.path).exists();
|
|
25
25
|
if (!exists) {
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const currentContent = await plugins.
|
|
30
|
-
change.path
|
|
31
|
-
|
|
29
|
+
const currentContent = (await plugins.smartfs
|
|
30
|
+
.file(change.path)
|
|
31
|
+
.encoding('utf8')
|
|
32
|
+
.read()) as string;
|
|
32
33
|
|
|
33
34
|
// For planned changes, we need the new content
|
|
34
35
|
if (!change.content) {
|
|
@@ -107,10 +108,10 @@ export class DiffReporter {
|
|
|
107
108
|
})),
|
|
108
109
|
};
|
|
109
110
|
|
|
110
|
-
await plugins.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
await plugins.smartfs
|
|
112
|
+
.file(outputPath)
|
|
113
|
+
.encoding('utf8')
|
|
114
|
+
.write(JSON.stringify(report, null, 2));
|
|
114
115
|
logger.log('info', `Diff report saved to ${outputPath}`);
|
|
115
116
|
}
|
|
116
117
|
|
|
@@ -192,10 +192,10 @@ export class FormatStats {
|
|
|
192
192
|
moduleStats: Array.from(this.stats.moduleStats.values()),
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
await plugins.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
await plugins.smartfs
|
|
196
|
+
.file(outputPath)
|
|
197
|
+
.encoding('utf8')
|
|
198
|
+
.write(JSON.stringify(report, null, 2));
|
|
199
199
|
logger.log('info', `Statistics report saved to ${outputPath}`);
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -36,21 +36,27 @@ export class RollbackManager {
|
|
|
36
36
|
: plugins.path.join(paths.cwd, filepath);
|
|
37
37
|
|
|
38
38
|
// Check if file exists
|
|
39
|
-
const exists = await plugins.
|
|
39
|
+
const exists = await plugins.smartfs.file(absolutePath).exists();
|
|
40
40
|
if (!exists) {
|
|
41
41
|
// File doesn't exist yet (will be created), so we skip backup
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Read file content and metadata
|
|
46
|
-
const content = plugins.
|
|
47
|
-
|
|
46
|
+
const content = (await plugins.smartfs
|
|
47
|
+
.file(absolutePath)
|
|
48
|
+
.encoding('utf8')
|
|
49
|
+
.read()) as string;
|
|
50
|
+
const stats = await plugins.smartfs.file(absolutePath).stat();
|
|
48
51
|
const checksum = this.calculateChecksum(content);
|
|
49
52
|
|
|
50
53
|
// Create backup
|
|
51
54
|
const backupPath = this.getBackupPath(operationId, filepath);
|
|
52
|
-
await plugins.
|
|
53
|
-
|
|
55
|
+
await plugins.smartfs
|
|
56
|
+
.directory(plugins.path.dirname(backupPath))
|
|
57
|
+
.recursive()
|
|
58
|
+
.create();
|
|
59
|
+
await plugins.smartfs.file(backupPath).encoding('utf8').write(content);
|
|
54
60
|
|
|
55
61
|
// Update operation
|
|
56
62
|
operation.files.push({
|
|
@@ -84,7 +90,10 @@ export class RollbackManager {
|
|
|
84
90
|
|
|
85
91
|
// Verify backup integrity
|
|
86
92
|
const backupPath = this.getBackupPath(operationId, file.path);
|
|
87
|
-
const backupContent = plugins.
|
|
93
|
+
const backupContent = await plugins.smartfs
|
|
94
|
+
.file(backupPath)
|
|
95
|
+
.encoding('utf8')
|
|
96
|
+
.read();
|
|
88
97
|
const backupChecksum = this.calculateChecksum(backupContent);
|
|
89
98
|
|
|
90
99
|
if (backupChecksum !== file.checksum) {
|
|
@@ -92,7 +101,10 @@ export class RollbackManager {
|
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
// Restore file
|
|
95
|
-
await plugins.
|
|
104
|
+
await plugins.smartfs
|
|
105
|
+
.file(absolutePath)
|
|
106
|
+
.encoding('utf8')
|
|
107
|
+
.write(file.originalContent);
|
|
96
108
|
|
|
97
109
|
// Restore permissions
|
|
98
110
|
const mode = parseInt(file.permissions, 8);
|
|
@@ -129,7 +141,7 @@ export class RollbackManager {
|
|
|
129
141
|
'operations',
|
|
130
142
|
operation.id,
|
|
131
143
|
);
|
|
132
|
-
await plugins.
|
|
144
|
+
await plugins.smartfs.directory(operationDir).recursive().delete();
|
|
133
145
|
|
|
134
146
|
// Remove from manifest
|
|
135
147
|
manifest.operations = manifest.operations.filter(
|
|
@@ -148,13 +160,16 @@ export class RollbackManager {
|
|
|
148
160
|
|
|
149
161
|
for (const file of operation.files) {
|
|
150
162
|
const backupPath = this.getBackupPath(operationId, file.path);
|
|
151
|
-
const exists = await plugins.
|
|
163
|
+
const exists = await plugins.smartfs.file(backupPath).exists();
|
|
152
164
|
|
|
153
165
|
if (!exists) {
|
|
154
166
|
return false;
|
|
155
167
|
}
|
|
156
168
|
|
|
157
|
-
const content = plugins.
|
|
169
|
+
const content = await plugins.smartfs
|
|
170
|
+
.file(backupPath)
|
|
171
|
+
.encoding('utf8')
|
|
172
|
+
.read();
|
|
158
173
|
const checksum = this.calculateChecksum(content);
|
|
159
174
|
|
|
160
175
|
if (checksum !== file.checksum) {
|
|
@@ -171,10 +186,11 @@ export class RollbackManager {
|
|
|
171
186
|
}
|
|
172
187
|
|
|
173
188
|
private async ensureBackupDir(): Promise<void> {
|
|
174
|
-
await plugins.
|
|
175
|
-
await plugins.
|
|
176
|
-
plugins.path.join(this.backupDir, 'operations')
|
|
177
|
-
|
|
189
|
+
await plugins.smartfs.directory(this.backupDir).recursive().create();
|
|
190
|
+
await plugins.smartfs
|
|
191
|
+
.directory(plugins.path.join(this.backupDir, 'operations'))
|
|
192
|
+
.recursive()
|
|
193
|
+
.create();
|
|
178
194
|
}
|
|
179
195
|
|
|
180
196
|
private generateOperationId(): string {
|
|
@@ -204,13 +220,16 @@ export class RollbackManager {
|
|
|
204
220
|
private async getManifest(): Promise<{ operations: IFormatOperation[] }> {
|
|
205
221
|
const defaultManifest = { operations: [] };
|
|
206
222
|
|
|
207
|
-
const exists = await plugins.
|
|
223
|
+
const exists = await plugins.smartfs.file(this.manifestPath).exists();
|
|
208
224
|
if (!exists) {
|
|
209
225
|
return defaultManifest;
|
|
210
226
|
}
|
|
211
227
|
|
|
212
228
|
try {
|
|
213
|
-
const content = plugins.
|
|
229
|
+
const content = (await plugins.smartfs
|
|
230
|
+
.file(this.manifestPath)
|
|
231
|
+
.encoding('utf8')
|
|
232
|
+
.read()) as string;
|
|
214
233
|
const manifest = JSON.parse(content);
|
|
215
234
|
|
|
216
235
|
// Validate the manifest structure
|
|
@@ -228,7 +247,7 @@ export class RollbackManager {
|
|
|
228
247
|
);
|
|
229
248
|
// Try to delete the corrupted file
|
|
230
249
|
try {
|
|
231
|
-
await plugins.
|
|
250
|
+
await plugins.smartfs.file(this.manifestPath).delete();
|
|
232
251
|
} catch (removeError) {
|
|
233
252
|
// Ignore removal errors
|
|
234
253
|
}
|
|
@@ -249,7 +268,10 @@ export class RollbackManager {
|
|
|
249
268
|
|
|
250
269
|
// Write directly with proper JSON stringification
|
|
251
270
|
const jsonContent = JSON.stringify(manifest, null, 2);
|
|
252
|
-
await plugins.
|
|
271
|
+
await plugins.smartfs
|
|
272
|
+
.file(this.manifestPath)
|
|
273
|
+
.encoding('utf8')
|
|
274
|
+
.write(jsonContent);
|
|
253
275
|
}
|
|
254
276
|
|
|
255
277
|
private async getOperation(
|
|
@@ -13,12 +13,12 @@ const filesToDelete = [
|
|
|
13
13
|
|
|
14
14
|
export const run = async (projectArg: Project) => {
|
|
15
15
|
for (const relativeFilePath of filesToDelete) {
|
|
16
|
-
const fileExists = plugins.
|
|
16
|
+
const fileExists = await plugins.smartfs.file(relativeFilePath).exists();
|
|
17
17
|
if (fileExists) {
|
|
18
18
|
logger.log('info', `Found ${relativeFilePath}! Removing it!`);
|
|
19
|
-
plugins.
|
|
20
|
-
plugins.path.join(paths.cwd, relativeFilePath)
|
|
21
|
-
|
|
19
|
+
await plugins.smartfs
|
|
20
|
+
.file(plugins.path.join(paths.cwd, relativeFilePath))
|
|
21
|
+
.delete();
|
|
22
22
|
} else {
|
|
23
23
|
logger.log('info', `Project is free of ${relativeFilePath}`);
|
|
24
24
|
}
|
|
@@ -24,7 +24,12 @@ export const run = async (projectArg: Project) => {
|
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
26
|
// Handle glob patterns
|
|
27
|
-
const
|
|
27
|
+
const entries = await plugins.smartfs
|
|
28
|
+
.directory('.')
|
|
29
|
+
.recursive()
|
|
30
|
+
.filter(pattern.from)
|
|
31
|
+
.list();
|
|
32
|
+
const files = entries.map((entry) => entry.path);
|
|
28
33
|
|
|
29
34
|
for (const file of files) {
|
|
30
35
|
const sourcePath = file;
|
|
@@ -46,10 +51,13 @@ export const run = async (projectArg: Project) => {
|
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
// Ensure destination directory exists
|
|
49
|
-
await plugins.
|
|
54
|
+
await plugins.smartfs
|
|
55
|
+
.directory(plugins.path.dirname(destPath))
|
|
56
|
+
.recursive()
|
|
57
|
+
.create();
|
|
50
58
|
|
|
51
59
|
// Copy file
|
|
52
|
-
await plugins.
|
|
60
|
+
await plugins.smartfs.file(sourcePath).copy(destPath);
|
|
53
61
|
logger.log('info', `Copied ${sourcePath} to ${destPath}`);
|
|
54
62
|
}
|
|
55
63
|
} catch (error) {
|
|
@@ -7,13 +7,15 @@ import { logger } from '../gitzone.logging.js';
|
|
|
7
7
|
const gitignorePath = plugins.path.join(paths.cwd, './.gitignore');
|
|
8
8
|
|
|
9
9
|
export const run = async (projectArg: Project) => {
|
|
10
|
-
const gitignoreExists = await plugins.
|
|
10
|
+
const gitignoreExists = await plugins.smartfs.file(gitignorePath).exists();
|
|
11
11
|
let customContent = '';
|
|
12
12
|
|
|
13
13
|
if (gitignoreExists) {
|
|
14
14
|
// lets get the existing gitignore file
|
|
15
|
-
const existingGitIgnoreString =
|
|
16
|
-
|
|
15
|
+
const existingGitIgnoreString = (await plugins.smartfs
|
|
16
|
+
.file(gitignorePath)
|
|
17
|
+
.encoding('utf8')
|
|
18
|
+
.read()) as string;
|
|
17
19
|
|
|
18
20
|
// Check for different custom section markers
|
|
19
21
|
const customMarkers = ['#------# custom', '# custom'];
|
|
@@ -34,12 +36,17 @@ export const run = async (projectArg: Project) => {
|
|
|
34
36
|
|
|
35
37
|
// Append the custom content if it exists
|
|
36
38
|
if (customContent) {
|
|
37
|
-
const newGitignoreContent =
|
|
38
|
-
|
|
39
|
+
const newGitignoreContent = (await plugins.smartfs
|
|
40
|
+
.file(gitignorePath)
|
|
41
|
+
.encoding('utf8')
|
|
42
|
+
.read()) as string;
|
|
39
43
|
// The template already ends with "#------# custom", so just append the content
|
|
40
44
|
const finalContent =
|
|
41
45
|
newGitignoreContent.trimEnd() + '\n' + customContent + '\n';
|
|
42
|
-
await plugins.
|
|
46
|
+
await plugins.smartfs
|
|
47
|
+
.file(gitignorePath)
|
|
48
|
+
.encoding('utf8')
|
|
49
|
+
.write(finalContent);
|
|
43
50
|
logger.log('info', 'Updated .gitignore while preserving custom section!');
|
|
44
51
|
} else {
|
|
45
52
|
logger.log('info', 'Added a .gitignore!');
|
|
@@ -7,9 +7,9 @@ import { logger } from '../gitzone.logging.js';
|
|
|
7
7
|
const incompatibleLicenses: string[] = ['AGPL', 'GPL', 'SSPL'];
|
|
8
8
|
|
|
9
9
|
export const run = async (projectArg: Project) => {
|
|
10
|
-
const nodeModulesInstalled = await plugins.
|
|
11
|
-
plugins.path.join(paths.cwd, 'node_modules')
|
|
12
|
-
|
|
10
|
+
const nodeModulesInstalled = await plugins.smartfs
|
|
11
|
+
.directory(plugins.path.join(paths.cwd, 'node_modules'))
|
|
12
|
+
.exists();
|
|
13
13
|
if (!nodeModulesInstalled) {
|
|
14
14
|
logger.log('warn', 'No node_modules found. Skipping license check');
|
|
15
15
|
return;
|
|
@@ -174,9 +174,11 @@ export const run = async (projectArg: Project) => {
|
|
|
174
174
|
);
|
|
175
175
|
|
|
176
176
|
// set overrides
|
|
177
|
-
const
|
|
178
|
-
plugins.path.join(paths.assetsDir, 'overrides.json')
|
|
179
|
-
|
|
177
|
+
const overridesContent = (await plugins.smartfs
|
|
178
|
+
.file(plugins.path.join(paths.assetsDir, 'overrides.json'))
|
|
179
|
+
.encoding('utf8')
|
|
180
|
+
.read()) as string;
|
|
181
|
+
const overrides = JSON.parse(overridesContent);
|
|
180
182
|
packageJson.pnpm = packageJson.pnpm || {};
|
|
181
183
|
packageJson.pnpm.overrides = overrides;
|
|
182
184
|
|
|
@@ -6,25 +6,22 @@ export const run = async () => {
|
|
|
6
6
|
const readmeHintsPath = plugins.path.join(paths.cwd, 'readme.hints.md');
|
|
7
7
|
|
|
8
8
|
// Check and initialize readme.md if it doesn't exist
|
|
9
|
-
const readmeExists = await plugins.
|
|
9
|
+
const readmeExists = await plugins.smartfs.file(readmePath).exists();
|
|
10
10
|
if (!readmeExists) {
|
|
11
|
-
await plugins.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
11
|
+
await plugins.smartfs.file(readmePath)
|
|
12
|
+
.encoding('utf8')
|
|
13
|
+
.write('# Project Readme\n\nThis is the initial readme file.');
|
|
15
14
|
console.log('Initialized readme.md');
|
|
16
15
|
} else {
|
|
17
16
|
console.log('readme.md already exists');
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
// Check and initialize readme.hints.md if it doesn't exist
|
|
21
|
-
const readmeHintsExists =
|
|
22
|
-
await plugins.smartfile.fs.fileExists(readmeHintsPath);
|
|
20
|
+
const readmeHintsExists = await plugins.smartfs.file(readmeHintsPath).exists();
|
|
23
21
|
if (!readmeHintsExists) {
|
|
24
|
-
await plugins.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
22
|
+
await plugins.smartfs.file(readmeHintsPath)
|
|
23
|
+
.encoding('utf8')
|
|
24
|
+
.write('# Project Readme Hints\n\nThis is the initial readme hints file.');
|
|
28
25
|
console.log('Initialized readme.hints.md');
|
|
29
26
|
} else {
|
|
30
27
|
console.log('readme.hints.md already exists');
|
|
@@ -7,10 +7,11 @@ import { Project } from '../classes.project.js';
|
|
|
7
7
|
export const run = async (projectArg: Project) => {
|
|
8
8
|
// lets care about tsconfig.json
|
|
9
9
|
logger.log('info', 'Formatting tsconfig.json...');
|
|
10
|
-
const
|
|
10
|
+
const factory = plugins.smartfile.SmartFileFactory.nodeFs();
|
|
11
|
+
const tsconfigSmartfile = await factory.fromFilePath(
|
|
11
12
|
plugins.path.join(paths.cwd, 'tsconfig.json'),
|
|
12
13
|
);
|
|
13
|
-
const tsconfigObject = JSON.parse(tsconfigSmartfile.
|
|
14
|
+
const tsconfigObject = JSON.parse(tsconfigSmartfile.parseContentAsString());
|
|
14
15
|
tsconfigObject.compilerOptions = tsconfigObject.compilerOptions || {};
|
|
15
16
|
tsconfigObject.compilerOptions.baseUrl = '.';
|
|
16
17
|
tsconfigObject.compilerOptions.paths = {};
|
|
@@ -23,8 +24,8 @@ export const run = async (projectArg: Project) => {
|
|
|
23
24
|
`./${publishModule}/index.js`,
|
|
24
25
|
];
|
|
25
26
|
}
|
|
26
|
-
tsconfigSmartfile.
|
|
27
|
-
JSON.stringify(tsconfigObject, null, 2)
|
|
28
|
-
);
|
|
27
|
+
await tsconfigSmartfile.editContentAsString(async () => {
|
|
28
|
+
return JSON.stringify(tsconfigObject, null, 2);
|
|
29
|
+
});
|
|
29
30
|
await tsconfigSmartfile.write();
|
|
30
31
|
};
|
|
@@ -20,7 +20,7 @@ export class CleanupFormatter extends BaseFormatter {
|
|
|
20
20
|
];
|
|
21
21
|
|
|
22
22
|
for (const file of filesToRemove) {
|
|
23
|
-
const exists = await plugins.
|
|
23
|
+
const exists = await plugins.smartfs.file(file).exists();
|
|
24
24
|
if (exists) {
|
|
25
25
|
changes.push({
|
|
26
26
|
type: 'delete',
|
|
@@ -41,16 +41,23 @@ export class PrettierFormatter extends BaseFormatter {
|
|
|
41
41
|
// Add files from TypeScript directories
|
|
42
42
|
for (const dir of includeDirs) {
|
|
43
43
|
const globPattern = `${dir}/**/*.${extensions}`;
|
|
44
|
-
const
|
|
45
|
-
'.'
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const dirEntries = await plugins.smartfs
|
|
45
|
+
.directory('.')
|
|
46
|
+
.recursive()
|
|
47
|
+
.filter(globPattern)
|
|
48
|
+
.list();
|
|
49
|
+
const dirFiles = dirEntries.map((entry) => entry.path);
|
|
48
50
|
allFiles.push(...dirFiles);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
// Add root config files
|
|
52
54
|
for (const pattern of rootConfigFiles) {
|
|
53
|
-
const
|
|
55
|
+
const rootEntries = await plugins.smartfs
|
|
56
|
+
.directory('.')
|
|
57
|
+
.recursive()
|
|
58
|
+
.filter(pattern)
|
|
59
|
+
.list();
|
|
60
|
+
const rootFiles = rootEntries.map((entry) => entry.path);
|
|
54
61
|
// Only include files at root level (no slashes in path)
|
|
55
62
|
const rootLevelFiles = rootFiles.filter((f) => !f.includes('/'));
|
|
56
63
|
allFiles.push(...rootLevelFiles);
|
|
@@ -66,8 +73,8 @@ export class PrettierFormatter extends BaseFormatter {
|
|
|
66
73
|
const validFiles: string[] = [];
|
|
67
74
|
for (const file of files) {
|
|
68
75
|
try {
|
|
69
|
-
const stats = await plugins.
|
|
70
|
-
if (!stats.isDirectory
|
|
76
|
+
const stats = await plugins.smartfs.file(file).stat();
|
|
77
|
+
if (!stats.isDirectory) {
|
|
71
78
|
validFiles.push(file);
|
|
72
79
|
}
|
|
73
80
|
} catch (error) {
|
|
@@ -148,7 +155,10 @@ export class PrettierFormatter extends BaseFormatter {
|
|
|
148
155
|
}
|
|
149
156
|
|
|
150
157
|
// Read current content
|
|
151
|
-
const content = plugins.
|
|
158
|
+
const content = (await plugins.smartfs
|
|
159
|
+
.file(change.path)
|
|
160
|
+
.encoding('utf8')
|
|
161
|
+
.read()) as string;
|
|
152
162
|
|
|
153
163
|
// Format with prettier
|
|
154
164
|
const prettier = await import('prettier');
|
package/ts/mod_format/index.ts
CHANGED
|
@@ -101,7 +101,12 @@ export let run = async (
|
|
|
101
101
|
// Plan phase
|
|
102
102
|
logger.log('info', 'Analyzing project for format operations...');
|
|
103
103
|
let plan = options.fromPlan
|
|
104
|
-
? JSON.parse(
|
|
104
|
+
? JSON.parse(
|
|
105
|
+
(await plugins.smartfs
|
|
106
|
+
.file(options.fromPlan)
|
|
107
|
+
.encoding('utf8')
|
|
108
|
+
.read()) as string,
|
|
109
|
+
)
|
|
105
110
|
: await planner.planFormat(activeFormatters);
|
|
106
111
|
|
|
107
112
|
// Display plan
|
|
@@ -109,10 +114,10 @@ export let run = async (
|
|
|
109
114
|
|
|
110
115
|
// Save plan if requested
|
|
111
116
|
if (options.savePlan) {
|
|
112
|
-
await plugins.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
await plugins.smartfs
|
|
118
|
+
.file(options.savePlan)
|
|
119
|
+
.encoding('utf8')
|
|
120
|
+
.write(JSON.stringify(plan, null, 2));
|
|
116
121
|
logger.log('info', `Plan saved to ${options.savePlan}`);
|
|
117
122
|
}
|
|
118
123
|
|
|
@@ -48,15 +48,17 @@ export class Meta {
|
|
|
48
48
|
public async readDirectory() {
|
|
49
49
|
await this.syncToRemote(true);
|
|
50
50
|
logger.log('info', `reading directory`);
|
|
51
|
-
const metaFileExists = plugins.
|
|
52
|
-
this.filePaths.metaJson
|
|
53
|
-
|
|
51
|
+
const metaFileExists = await plugins.smartfs
|
|
52
|
+
.file(this.filePaths.metaJson)
|
|
53
|
+
.exists();
|
|
54
54
|
if (!metaFileExists) {
|
|
55
55
|
throw new Error(`meta file does not exist at ${this.filePaths.metaJson}`);
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
this.filePaths.metaJson
|
|
59
|
-
|
|
57
|
+
const content = (await plugins.smartfs
|
|
58
|
+
.file(this.filePaths.metaJson)
|
|
59
|
+
.encoding('utf8')
|
|
60
|
+
.read()) as string;
|
|
61
|
+
this.metaRepoData = JSON.parse(content);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
/**
|
|
@@ -78,15 +80,15 @@ export class Meta {
|
|
|
78
80
|
*/
|
|
79
81
|
public async writeToDisk() {
|
|
80
82
|
// write .meta.json to disk
|
|
81
|
-
plugins.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
await plugins.smartfs
|
|
84
|
+
.file(this.filePaths.metaJson)
|
|
85
|
+
.encoding('utf8')
|
|
86
|
+
.write(JSON.stringify(this.metaRepoData, null, 2));
|
|
85
87
|
// write .gitignore to disk
|
|
86
|
-
plugins.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
await plugins.smartfs
|
|
89
|
+
.file(this.filePaths.gitIgnore)
|
|
90
|
+
.encoding('utf8')
|
|
91
|
+
.write(await this.generateGitignore());
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
/**
|
|
@@ -112,10 +114,25 @@ export class Meta {
|
|
|
112
114
|
*/
|
|
113
115
|
public async updateLocalRepos() {
|
|
114
116
|
await this.syncToRemote();
|
|
115
|
-
const
|
|
116
|
-
this.filePaths.metaJson
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
const metaContent = (await plugins.smartfs
|
|
118
|
+
.file(this.filePaths.metaJson)
|
|
119
|
+
.encoding('utf8')
|
|
120
|
+
.read()) as string;
|
|
121
|
+
const projects = JSON.parse(metaContent).projects;
|
|
122
|
+
const entries = await plugins.smartfs.directory(this.cwd).list();
|
|
123
|
+
const preExistingFolders: string[] = [];
|
|
124
|
+
for (const entry of entries) {
|
|
125
|
+
try {
|
|
126
|
+
const stats = await plugins.smartfs
|
|
127
|
+
.file(plugins.path.join(this.cwd, entry.path))
|
|
128
|
+
.stat();
|
|
129
|
+
if (stats.isDirectory) {
|
|
130
|
+
preExistingFolders.push(entry.name);
|
|
131
|
+
}
|
|
132
|
+
} catch {
|
|
133
|
+
// Skip entries that can't be accessed
|
|
134
|
+
}
|
|
135
|
+
}
|
|
119
136
|
for (const preExistingFolderArg of preExistingFolders) {
|
|
120
137
|
if (
|
|
121
138
|
preExistingFolderArg !== '.git' &&
|
|
@@ -143,9 +160,17 @@ export class Meta {
|
|
|
143
160
|
await this.sortMetaRepoData();
|
|
144
161
|
const missingRepos: string[] = [];
|
|
145
162
|
for (const key of Object.keys(this.metaRepoData.projects)) {
|
|
146
|
-
plugins.
|
|
147
|
-
|
|
148
|
-
|
|
163
|
+
const fullPath = plugins.path.join(this.cwd, key);
|
|
164
|
+
try {
|
|
165
|
+
const stats = await plugins.smartfs.file(fullPath).stat();
|
|
166
|
+
if (stats.isDirectory) {
|
|
167
|
+
logger.log('ok', `${key} -> is already cloned`);
|
|
168
|
+
} else {
|
|
169
|
+
missingRepos.push(key);
|
|
170
|
+
}
|
|
171
|
+
} catch {
|
|
172
|
+
missingRepos.push(key);
|
|
173
|
+
}
|
|
149
174
|
}
|
|
150
175
|
|
|
151
176
|
logger.log('info', `found ${missingRepos.length} missing repos`);
|
|
@@ -165,7 +190,20 @@ export class Meta {
|
|
|
165
190
|
await this.syncToRemote();
|
|
166
191
|
|
|
167
192
|
// go recursive
|
|
168
|
-
const
|
|
193
|
+
const listEntries = await plugins.smartfs.directory(this.cwd).list();
|
|
194
|
+
const folders: string[] = [];
|
|
195
|
+
for (const entry of listEntries) {
|
|
196
|
+
try {
|
|
197
|
+
const stats = await plugins.smartfs
|
|
198
|
+
.file(plugins.path.join(this.cwd, entry.path))
|
|
199
|
+
.stat();
|
|
200
|
+
if (stats.isDirectory) {
|
|
201
|
+
folders.push(entry.name);
|
|
202
|
+
}
|
|
203
|
+
} catch {
|
|
204
|
+
// Skip entries that can't be accessed
|
|
205
|
+
}
|
|
206
|
+
}
|
|
169
207
|
const childMetaRepositories: string[] = [];
|
|
170
208
|
for (const folder of folders) {
|
|
171
209
|
logger.log('info', folder);
|
|
@@ -180,27 +218,31 @@ export class Meta {
|
|
|
180
218
|
*/
|
|
181
219
|
public async initProject() {
|
|
182
220
|
await this.syncToRemote(true);
|
|
183
|
-
const fileExists = await plugins.
|
|
184
|
-
this.filePaths.metaJson
|
|
185
|
-
|
|
221
|
+
const fileExists = await plugins.smartfs
|
|
222
|
+
.file(this.filePaths.metaJson)
|
|
223
|
+
.exists();
|
|
186
224
|
if (!fileExists) {
|
|
187
|
-
await plugins.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
225
|
+
await plugins.smartfs
|
|
226
|
+
.file(this.filePaths.metaJson)
|
|
227
|
+
.encoding('utf8')
|
|
228
|
+
.write(
|
|
229
|
+
JSON.stringify({
|
|
230
|
+
projects: {},
|
|
231
|
+
}),
|
|
232
|
+
);
|
|
193
233
|
logger.log(
|
|
194
234
|
`success`,
|
|
195
235
|
`created a new .meta.json in directory ${this.cwd}`,
|
|
196
236
|
);
|
|
197
|
-
await plugins.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
237
|
+
await plugins.smartfs
|
|
238
|
+
.file(this.filePaths.packageJson)
|
|
239
|
+
.encoding('utf8')
|
|
240
|
+
.write(
|
|
241
|
+
JSON.stringify({
|
|
242
|
+
name: this.dirName,
|
|
243
|
+
version: '1.0.0',
|
|
244
|
+
}),
|
|
245
|
+
);
|
|
204
246
|
logger.log(
|
|
205
247
|
`success`,
|
|
206
248
|
`created a new package.json in directory ${this.cwd}`,
|
|
@@ -264,9 +306,10 @@ export class Meta {
|
|
|
264
306
|
await this.writeToDisk();
|
|
265
307
|
|
|
266
308
|
logger.log('info', 'removing directory from cwd');
|
|
267
|
-
await plugins.
|
|
268
|
-
plugins.path.join(paths.cwd, projectNameArg)
|
|
269
|
-
|
|
309
|
+
await plugins.smartfs
|
|
310
|
+
.directory(plugins.path.join(paths.cwd, projectNameArg))
|
|
311
|
+
.recursive()
|
|
312
|
+
.delete();
|
|
270
313
|
await this.updateLocalRepos();
|
|
271
314
|
}
|
|
272
315
|
}
|