BREAKING CHANGE(core): Migrate filesystem to smartfs (async) and add Elasticsearch service support; refactor format/commit/meta modules
This commit is contained in:
@@ -243,7 +243,60 @@ gitzone format --clean-backups
|
||||
|
||||
## API Changes
|
||||
|
||||
- smartfile API updated to use fs._ and memory._ namespaces
|
||||
### Smartfile v13 Migration (Latest - Completed)
|
||||
|
||||
The project has been fully migrated from @push.rocks/smartfile v11 to v13, which introduced a major breaking change where filesystem operations were split into two separate packages:
|
||||
|
||||
**Packages:**
|
||||
- `@push.rocks/smartfile` v13.0.1 - File representation classes (SmartFile, StreamFile, VirtualDirectory)
|
||||
- `@push.rocks/smartfs` v1.1.0 - Filesystem operations (read, write, exists, stat, etc.)
|
||||
|
||||
**Key API Changes:**
|
||||
1. **File Reading**:
|
||||
- Old: `plugins.smartfile.fs.toStringSync(path)` or `plugins.smartfile.fs.toObjectSync(path)`
|
||||
- New: `await plugins.smartfs.file(path).encoding('utf8').read()` + JSON.parse if needed
|
||||
- Important: `read()` returns `string | Buffer` - use `as string` type assertion when encoding is set
|
||||
|
||||
2. **File Writing**:
|
||||
- Old: `plugins.smartfile.memory.toFs(content, path)` or `plugins.smartfile.memory.toFsSync(content, path)`
|
||||
- New: `await plugins.smartfs.file(path).encoding('utf8').write(content)`
|
||||
|
||||
3. **File Existence**:
|
||||
- Old: `plugins.smartfile.fs.fileExists(path)` or `plugins.smartfile.fs.fileExistsSync(path)`
|
||||
- New: `await plugins.smartfs.file(path).exists()`
|
||||
|
||||
4. **Directory Operations**:
|
||||
- Old: `plugins.smartfile.fs.ensureDir(path)`
|
||||
- New: `await plugins.smartfs.directory(path).recursive().create()`
|
||||
- Old: `plugins.smartfile.fs.remove(path)`
|
||||
- New: `await plugins.smartfs.directory(path).recursive().delete()` or `await plugins.smartfs.file(path).delete()`
|
||||
|
||||
5. **Directory Listing**:
|
||||
- Old: `plugins.smartfile.fs.listFolders(path)` or `plugins.smartfile.fs.listFoldersSync(path)`
|
||||
- New: `await plugins.smartfs.directory(path).list()` then filter by `stats.isDirectory`
|
||||
- Note: `list()` returns `IDirectoryEntry[]` with `path` and `name` properties - use `stat()` to check if directory
|
||||
|
||||
6. **File Stats**:
|
||||
- Old: `stats.isDirectory()` (method)
|
||||
- New: `stats.isDirectory` (boolean property)
|
||||
- Old: `stats.mtimeMs`
|
||||
- New: `stats.mtime.getTime()`
|
||||
|
||||
7. **SmartFile Factory**:
|
||||
- Old: Direct SmartFile instantiation
|
||||
- New: `plugins.smartfile.SmartFileFactory.nodeFs()` then factory methods
|
||||
|
||||
**Migration Pattern:**
|
||||
All sync methods must become async. Functions that were previously synchronous (like `getProjectName()`) now return `Promise<T>` and must be awaited.
|
||||
|
||||
**Affected Modules:**
|
||||
- ts/mod_format/* (largest area - 15+ files)
|
||||
- ts/mod_commit/* (version bumping)
|
||||
- ts/mod_services/* (configuration management)
|
||||
- ts/mod_meta/* (meta repository management)
|
||||
- ts/mod_standard/* (template listing)
|
||||
- ts/mod_template/* (template operations)
|
||||
|
||||
**Previous API Changes:**
|
||||
- smartnpm requires instance creation: `new NpmRegistry()`
|
||||
- All file operations now use updated APIs
|
||||
- Type imports use `import type` for proper verbatim module syntax
|
||||
|
||||
Reference in New Issue
Block a user