@git.zone/cli 1.21.5 → 2.1.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.
Files changed (61) hide show
  1. package/dist_ts/00_commitinfo_data.js +2 -2
  2. package/dist_ts/mod_commit/index.js +5 -2
  3. package/dist_ts/mod_commit/mod.helpers.js +24 -9
  4. package/dist_ts/mod_format/classes.baseformatter.js +4 -4
  5. package/dist_ts/mod_format/classes.changecache.js +29 -17
  6. package/dist_ts/mod_format/classes.diffreporter.js +10 -4
  7. package/dist_ts/mod_format/classes.formatstats.js +5 -2
  8. package/dist_ts/mod_format/classes.rollbackmanager.js +41 -17
  9. package/dist_ts/mod_format/format.cleanup.js +5 -3
  10. package/dist_ts/mod_format/format.copy.js +12 -4
  11. package/dist_ts/mod_format/format.gitignore.js +14 -5
  12. package/dist_ts/mod_format/format.license.js +4 -2
  13. package/dist_ts/mod_format/format.packagejson.js +6 -2
  14. package/dist_ts/mod_format/format.readme.js +9 -5
  15. package/dist_ts/mod_format/format.tsconfig.js +7 -4
  16. package/dist_ts/mod_format/formatters/cleanup.formatter.js +2 -2
  17. package/dist_ts/mod_format/formatters/prettier.formatter.js +19 -6
  18. package/dist_ts/mod_format/index.js +9 -3
  19. package/dist_ts/mod_meta/meta.classes.meta.js +82 -17
  20. package/dist_ts/mod_services/classes.globalregistry.d.ts +77 -0
  21. package/dist_ts/mod_services/classes.globalregistry.js +133 -0
  22. package/dist_ts/mod_services/classes.serviceconfiguration.d.ts +7 -0
  23. package/dist_ts/mod_services/classes.serviceconfiguration.js +86 -10
  24. package/dist_ts/mod_services/classes.servicemanager.d.ts +38 -0
  25. package/dist_ts/mod_services/classes.servicemanager.js +353 -10
  26. package/dist_ts/mod_services/helpers.d.ts +1 -1
  27. package/dist_ts/mod_services/helpers.js +8 -4
  28. package/dist_ts/mod_services/index.js +194 -28
  29. package/dist_ts/mod_standard/index.js +22 -9
  30. package/dist_ts/mod_template/index.js +2 -2
  31. package/dist_ts/plugins.d.ts +2 -0
  32. package/dist_ts/plugins.js +4 -1
  33. package/package.json +7 -6
  34. package/readme.hints.md +55 -2
  35. package/ts/00_commitinfo_data.ts +1 -1
  36. package/ts/mod_commit/index.ts +4 -4
  37. package/ts/mod_commit/mod.helpers.ts +23 -11
  38. package/ts/mod_format/classes.baseformatter.ts +3 -3
  39. package/ts/mod_format/classes.changecache.ts +28 -16
  40. package/ts/mod_format/classes.diffreporter.ts +9 -8
  41. package/ts/mod_format/classes.formatstats.ts +4 -4
  42. package/ts/mod_format/classes.rollbackmanager.ts +40 -18
  43. package/ts/mod_format/format.cleanup.ts +4 -4
  44. package/ts/mod_format/format.copy.ts +11 -3
  45. package/ts/mod_format/format.gitignore.ts +13 -6
  46. package/ts/mod_format/format.license.ts +3 -3
  47. package/ts/mod_format/format.packagejson.ts +5 -3
  48. package/ts/mod_format/format.readme.ts +8 -11
  49. package/ts/mod_format/format.tsconfig.ts +6 -5
  50. package/ts/mod_format/formatters/cleanup.formatter.ts +1 -1
  51. package/ts/mod_format/formatters/prettier.formatter.ts +18 -8
  52. package/ts/mod_format/index.ts +10 -5
  53. package/ts/mod_meta/meta.classes.meta.ts +84 -41
  54. package/ts/mod_services/classes.globalregistry.ts +190 -0
  55. package/ts/mod_services/classes.serviceconfiguration.ts +121 -35
  56. package/ts/mod_services/classes.servicemanager.ts +405 -32
  57. package/ts/mod_services/helpers.ts +8 -4
  58. package/ts/mod_services/index.ts +257 -48
  59. package/ts/mod_standard/index.ts +23 -10
  60. package/ts/mod_template/index.ts +1 -1
  61. package/ts/plugins.ts +4 -0
@@ -40,8 +40,8 @@ export async function detectProjectType(): Promise<ProjectType> {
40
40
  const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
41
41
  const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
42
42
 
43
- const hasPackageJson = await plugins.smartfile.fs.fileExists(packageJsonPath);
44
- const hasDenoJson = await plugins.smartfile.fs.fileExists(denoJsonPath);
43
+ const hasPackageJson = await plugins.smartfs.file(packageJsonPath).exists();
44
+ const hasDenoJson = await plugins.smartfs.file(denoJsonPath).exists();
45
45
 
46
46
  if (hasPackageJson && hasDenoJson) {
47
47
  logger.log('info', 'Detected dual project (npm + deno)');
@@ -95,10 +95,14 @@ function calculateNewVersion(currentVersion: string, versionType: VersionType):
95
95
  * @param projectType The project type to determine which file to read
96
96
  * @returns The current version string
97
97
  */
98
- function readCurrentVersion(projectType: ProjectType): string {
98
+ async function readCurrentVersion(projectType: ProjectType): Promise<string> {
99
99
  if (projectType === 'npm' || projectType === 'both') {
100
100
  const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
101
- const packageJson = plugins.smartfile.fs.toObjectSync(packageJsonPath) as { version?: string };
101
+ const content = (await plugins.smartfs
102
+ .file(packageJsonPath)
103
+ .encoding('utf8')
104
+ .read()) as string;
105
+ const packageJson = JSON.parse(content) as { version?: string };
102
106
 
103
107
  if (!packageJson.version) {
104
108
  throw new Error('package.json does not contain a version field');
@@ -106,7 +110,11 @@ function readCurrentVersion(projectType: ProjectType): string {
106
110
  return packageJson.version;
107
111
  } else {
108
112
  const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
109
- const denoConfig = plugins.smartfile.fs.toObjectSync(denoJsonPath) as { version?: string };
113
+ const content = (await plugins.smartfs
114
+ .file(denoJsonPath)
115
+ .encoding('utf8')
116
+ .read()) as string;
117
+ const denoConfig = JSON.parse(content) as { version?: string };
110
118
 
111
119
  if (!denoConfig.version) {
112
120
  throw new Error('deno.json does not contain a version field');
@@ -121,12 +129,16 @@ function readCurrentVersion(projectType: ProjectType): string {
121
129
  * @param newVersion The new version to write
122
130
  */
123
131
  async function updateVersionFile(filePath: string, newVersion: string): Promise<void> {
124
- const config = plugins.smartfile.fs.toObjectSync(filePath) as { version?: string };
132
+ const content = (await plugins.smartfs
133
+ .file(filePath)
134
+ .encoding('utf8')
135
+ .read()) as string;
136
+ const config = JSON.parse(content) as { version?: string };
125
137
  config.version = newVersion;
126
- await plugins.smartfile.memory.toFs(
127
- JSON.stringify(config, null, 2) + '\n',
128
- filePath
129
- );
138
+ await plugins.smartfs
139
+ .file(filePath)
140
+ .encoding('utf8')
141
+ .write(JSON.stringify(config, null, 2) + '\n');
130
142
  }
131
143
 
132
144
  /**
@@ -162,7 +174,7 @@ export async function bumpProjectVersion(
162
174
 
163
175
  try {
164
176
  // 1. Read current version
165
- const currentVersion = readCurrentVersion(projectType);
177
+ const currentVersion = await readCurrentVersion(projectType);
166
178
 
167
179
  // 2. Calculate new version (reuse existing function!)
168
180
  const newVersion = calculateNewVersion(currentVersion, versionType);
@@ -65,15 +65,15 @@ export abstract class BaseFormatter {
65
65
  normalizedPath = './' + filepath;
66
66
  }
67
67
 
68
- await plugins.smartfile.memory.toFs(content, normalizedPath);
68
+ await plugins.smartfs.file(normalizedPath).encoding('utf8').write(content);
69
69
  }
70
70
 
71
71
  protected async createFile(filepath: string, content: string): Promise<void> {
72
- await plugins.smartfile.memory.toFs(content, filepath);
72
+ await plugins.smartfs.file(filepath).encoding('utf8').write(content);
73
73
  }
74
74
 
75
75
  protected async deleteFile(filepath: string): Promise<void> {
76
- await plugins.smartfile.fs.remove(filepath);
76
+ await plugins.smartfs.file(filepath).delete();
77
77
  }
78
78
 
79
79
  protected async shouldProcessFile(filepath: string): Promise<boolean> {
@@ -25,7 +25,7 @@ export class ChangeCache {
25
25
  }
26
26
 
27
27
  async initialize(): Promise<void> {
28
- await plugins.smartfile.fs.ensureDir(this.cacheDir);
28
+ await plugins.smartfs.directory(this.cacheDir).recursive().create();
29
29
  }
30
30
 
31
31
  async getManifest(): Promise<ICacheManifest> {
@@ -35,13 +35,16 @@ export class ChangeCache {
35
35
  files: [],
36
36
  };
37
37
 
38
- const exists = await plugins.smartfile.fs.fileExists(this.manifestPath);
38
+ const exists = await plugins.smartfs.file(this.manifestPath).exists();
39
39
  if (!exists) {
40
40
  return defaultManifest;
41
41
  }
42
42
 
43
43
  try {
44
- const content = plugins.smartfile.fs.toStringSync(this.manifestPath);
44
+ const content = (await plugins.smartfs
45
+ .file(this.manifestPath)
46
+ .encoding('utf8')
47
+ .read()) as string;
45
48
  const manifest = JSON.parse(content);
46
49
 
47
50
  // Validate the manifest structure
@@ -57,7 +60,7 @@ export class ChangeCache {
57
60
  );
58
61
  // Try to delete the corrupted file
59
62
  try {
60
- await plugins.smartfile.fs.remove(this.manifestPath);
63
+ await plugins.smartfs.file(this.manifestPath).delete();
61
64
  } catch (removeError) {
62
65
  // Ignore removal errors
63
66
  }
@@ -72,11 +75,14 @@ export class ChangeCache {
72
75
  }
73
76
 
74
77
  // Ensure directory exists
75
- await plugins.smartfile.fs.ensureDir(this.cacheDir);
78
+ await plugins.smartfs.directory(this.cacheDir).recursive().create();
76
79
 
77
80
  // Write directly with proper JSON stringification
78
81
  const jsonContent = JSON.stringify(manifest, null, 2);
79
- await plugins.smartfile.memory.toFs(jsonContent, this.manifestPath);
82
+ await plugins.smartfs
83
+ .file(this.manifestPath)
84
+ .encoding('utf8')
85
+ .write(jsonContent);
80
86
  }
81
87
 
82
88
  async hasFileChanged(filePath: string): Promise<boolean> {
@@ -85,20 +91,23 @@ export class ChangeCache {
85
91
  : plugins.path.join(paths.cwd, filePath);
86
92
 
87
93
  // Check if file exists
88
- const exists = await plugins.smartfile.fs.fileExists(absolutePath);
94
+ const exists = await plugins.smartfs.file(absolutePath).exists();
89
95
  if (!exists) {
90
96
  return true; // File doesn't exist, so it's "changed" (will be created)
91
97
  }
92
98
 
93
99
  // Get current file stats
94
- const stats = await plugins.smartfile.fs.stat(absolutePath);
100
+ const stats = await plugins.smartfs.file(absolutePath).stat();
95
101
 
96
102
  // Skip directories
97
- if (stats.isDirectory()) {
103
+ if (stats.isDirectory) {
98
104
  return false; // Directories are not processed
99
105
  }
100
106
 
101
- const content = plugins.smartfile.fs.toStringSync(absolutePath);
107
+ const content = (await plugins.smartfs
108
+ .file(absolutePath)
109
+ .encoding('utf8')
110
+ .read()) as string;
102
111
  const currentChecksum = this.calculateChecksum(content);
103
112
 
104
113
  // Get cached info
@@ -113,7 +122,7 @@ export class ChangeCache {
113
122
  return (
114
123
  cachedFile.checksum !== currentChecksum ||
115
124
  cachedFile.size !== stats.size ||
116
- cachedFile.modified !== stats.mtimeMs
125
+ cachedFile.modified !== stats.mtime.getTime()
117
126
  );
118
127
  }
119
128
 
@@ -123,14 +132,17 @@ export class ChangeCache {
123
132
  : plugins.path.join(paths.cwd, filePath);
124
133
 
125
134
  // Get current file stats
126
- const stats = await plugins.smartfile.fs.stat(absolutePath);
135
+ const stats = await plugins.smartfs.file(absolutePath).stat();
127
136
 
128
137
  // Skip directories
129
- if (stats.isDirectory()) {
138
+ if (stats.isDirectory) {
130
139
  return; // Don't cache directories
131
140
  }
132
141
 
133
- const content = plugins.smartfile.fs.toStringSync(absolutePath);
142
+ const content = (await plugins.smartfs
143
+ .file(absolutePath)
144
+ .encoding('utf8')
145
+ .read()) as string;
134
146
  const checksum = this.calculateChecksum(content);
135
147
 
136
148
  // Update manifest
@@ -140,7 +152,7 @@ export class ChangeCache {
140
152
  const cacheEntry: IFileCache = {
141
153
  path: filePath,
142
154
  checksum,
143
- modified: stats.mtimeMs,
155
+ modified: stats.mtime.getTime(),
144
156
  size: stats.size,
145
157
  };
146
158
 
@@ -176,7 +188,7 @@ export class ChangeCache {
176
188
  ? file.path
177
189
  : plugins.path.join(paths.cwd, file.path);
178
190
 
179
- if (await plugins.smartfile.fs.fileExists(absolutePath)) {
191
+ if (await plugins.smartfs.file(absolutePath).exists()) {
180
192
  validFiles.push(file);
181
193
  }
182
194
  }
@@ -21,14 +21,15 @@ export class DiffReporter {
21
21
  }
22
22
 
23
23
  try {
24
- const exists = await plugins.smartfile.fs.fileExists(change.path);
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.smartfile.fs.toStringSync(
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.smartfile.memory.toFs(
111
- JSON.stringify(report, null, 2),
112
- outputPath,
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.smartfile.memory.toFs(
196
- JSON.stringify(report, null, 2),
197
- outputPath,
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.smartfile.fs.fileExists(absolutePath);
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.smartfile.fs.toStringSync(absolutePath);
47
- const stats = await plugins.smartfile.fs.stat(absolutePath);
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.smartfile.fs.ensureDir(plugins.path.dirname(backupPath));
53
- await plugins.smartfile.memory.toFs(content, backupPath);
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.smartfile.fs.toStringSync(backupPath);
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.smartfile.memory.toFs(file.originalContent, absolutePath);
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.smartfile.fs.remove(operationDir);
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.smartfile.fs.fileExists(backupPath);
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.smartfile.fs.toStringSync(backupPath);
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.smartfile.fs.ensureDir(this.backupDir);
175
- await plugins.smartfile.fs.ensureDir(
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.smartfile.fs.fileExists(this.manifestPath);
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.smartfile.fs.toStringSync(this.manifestPath);
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.smartfile.fs.remove(this.manifestPath);
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.smartfile.memory.toFs(jsonContent, this.manifestPath);
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.smartfile.fs.fileExistsSync(relativeFilePath);
16
+ const fileExists = await plugins.smartfs.file(relativeFilePath).exists();
17
17
  if (fileExists) {
18
18
  logger.log('info', `Found ${relativeFilePath}! Removing it!`);
19
- plugins.smartfile.fs.removeSync(
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 files = await plugins.smartfile.fs.listFileTree('.', pattern.from);
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.smartfile.fs.ensureDir(plugins.path.dirname(destPath));
54
+ await plugins.smartfs
55
+ .directory(plugins.path.dirname(destPath))
56
+ .recursive()
57
+ .create();
50
58
 
51
59
  // Copy file
52
- await plugins.smartfile.fs.copy(sourcePath, destPath);
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.smartfile.fs.fileExists(gitignorePath);
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
- plugins.smartfile.fs.toStringSync(gitignorePath);
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
- plugins.smartfile.fs.toStringSync(gitignorePath);
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.smartfile.fs.toFs(finalContent, gitignorePath);
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.smartfile.fs.isDirectory(
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 overrides = plugins.smartfile.fs.toObjectSync(
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.smartfile.fs.fileExists(readmePath);
9
+ const readmeExists = await plugins.smartfs.file(readmePath).exists();
10
10
  if (!readmeExists) {
11
- await plugins.smartfile.fs.toFs(
12
- '# Project Readme\n\nThis is the initial readme file.',
13
- readmePath,
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.smartfile.fs.toFs(
25
- '# Project Readme Hints\n\nThis is the initial readme hints file.',
26
- readmeHintsPath,
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 tsconfigSmartfile = await plugins.smartfile.SmartFile.fromFilePath(
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.contentBuffer.toString());
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.setContentsFromString(
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.smartfile.fs.fileExists(file);
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 dirFiles = await plugins.smartfile.fs.listFileTree(
45
- '.',
46
- globPattern,
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 rootFiles = await plugins.smartfile.fs.listFileTree('.', pattern);
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.smartfile.fs.stat(file);
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.smartfile.fs.toStringSync(change.path);
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');