@akanjs/devkit 0.9.55 → 0.9.57

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.
@@ -222,10 +222,10 @@ class Executor {
222
222
  this.logger.verbose(`Remove file ${readPath}`);
223
223
  return this;
224
224
  }
225
- removeDir(dirPath) {
225
+ async removeDir(dirPath) {
226
226
  const readPath = this.getPath(dirPath);
227
227
  if (import_fs.default.existsSync(readPath))
228
- import_fs.default.rmSync(readPath, { recursive: true });
228
+ await import_fs.default.promises.rm(readPath, { recursive: true });
229
229
  this.logger.verbose(`Remove directory ${readPath}`);
230
230
  return this;
231
231
  }
@@ -273,7 +273,8 @@ class Executor {
273
273
  const dest = this.getPath(destPath);
274
274
  if (!import_fs.default.existsSync(src))
275
275
  return;
276
- if (!import_fs.default.existsSync(dest))
276
+ const isDirectory = import_fs.default.statSync(src).isDirectory();
277
+ if (!import_fs.default.existsSync(dest) && isDirectory)
277
278
  await import_promises.default.mkdir(dest, { recursive: true });
278
279
  await import_promises.default.cp(src, dest, { recursive: true });
279
280
  }
@@ -828,32 +829,23 @@ class AppExecutor extends SysExecutor {
828
829
  return this.#akanConfig;
829
830
  }
830
831
  async syncAssets(libDeps) {
831
- const projectPublicLibPath = `${this.cwdPath}/public/libs`;
832
- const projectAssetsLibPath = `${this.cwdPath}/assets/libs`;
832
+ const projectPublicPath = `${this.cwdPath}/public`;
833
+ const projectAssetsPath = `${this.cwdPath}/assets`;
834
+ const projectPublicLibPath = `${projectPublicPath}/libs`;
835
+ const projectAssetsLibPath = `${projectAssetsPath}/libs`;
836
+ await Promise.all([this.removeDir(projectPublicLibPath), this.removeDir(projectAssetsLibPath)]);
837
+ const targetPublicDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
838
+ const targetAssetsDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/assets`));
833
839
  await Promise.all([
834
- import_fs.default.existsSync(projectPublicLibPath) && import_promises.default.rm(projectPublicLibPath, { recursive: true }),
835
- import_fs.default.existsSync(projectAssetsLibPath) && import_promises.default.rm(projectAssetsLibPath, { recursive: true })
836
- ]);
837
- const targetPublicDeps = libDeps.filter(
838
- (dep) => import_fs.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`)
839
- );
840
- const targetAssetsDeps = libDeps.filter(
841
- (dep) => import_fs.default.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`)
842
- );
843
- await Promise.all([
844
- ...targetPublicDeps.map((dep) => import_promises.default.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })),
845
- ...targetAssetsDeps.map((dep) => import_promises.default.mkdir(`${projectAssetsLibPath}/${dep}`, { recursive: true }))
840
+ ...targetPublicDeps.map((dep) => this.mkdir(`${projectPublicLibPath}/${dep}`)),
841
+ ...targetAssetsDeps.map((dep) => this.mkdir(`${projectAssetsLibPath}/${dep}`))
846
842
  ]);
847
843
  await Promise.all([
848
844
  ...targetPublicDeps.map(
849
- (dep) => import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
850
- recursive: true
851
- })
845
+ (dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`)
852
846
  ),
853
847
  ...targetAssetsDeps.map(
854
- (dep) => import_promises.default.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`, {
855
- recursive: true
856
- })
848
+ (dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`)
857
849
  )
858
850
  ]);
859
851
  }
@@ -182,10 +182,10 @@ class Executor {
182
182
  this.logger.verbose(`Remove file ${readPath}`);
183
183
  return this;
184
184
  }
185
- removeDir(dirPath) {
185
+ async removeDir(dirPath) {
186
186
  const readPath = this.getPath(dirPath);
187
187
  if (fs.existsSync(readPath))
188
- fs.rmSync(readPath, { recursive: true });
188
+ await fs.promises.rm(readPath, { recursive: true });
189
189
  this.logger.verbose(`Remove directory ${readPath}`);
190
190
  return this;
191
191
  }
@@ -233,7 +233,8 @@ class Executor {
233
233
  const dest = this.getPath(destPath);
234
234
  if (!fs.existsSync(src))
235
235
  return;
236
- if (!fs.existsSync(dest))
236
+ const isDirectory = fs.statSync(src).isDirectory();
237
+ if (!fs.existsSync(dest) && isDirectory)
237
238
  await fsPromise.mkdir(dest, { recursive: true });
238
239
  await fsPromise.cp(src, dest, { recursive: true });
239
240
  }
@@ -788,32 +789,23 @@ class AppExecutor extends SysExecutor {
788
789
  return this.#akanConfig;
789
790
  }
790
791
  async syncAssets(libDeps) {
791
- const projectPublicLibPath = `${this.cwdPath}/public/libs`;
792
- const projectAssetsLibPath = `${this.cwdPath}/assets/libs`;
792
+ const projectPublicPath = `${this.cwdPath}/public`;
793
+ const projectAssetsPath = `${this.cwdPath}/assets`;
794
+ const projectPublicLibPath = `${projectPublicPath}/libs`;
795
+ const projectAssetsLibPath = `${projectAssetsPath}/libs`;
796
+ await Promise.all([this.removeDir(projectPublicLibPath), this.removeDir(projectAssetsLibPath)]);
797
+ const targetPublicDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
798
+ const targetAssetsDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/assets`));
793
799
  await Promise.all([
794
- fs.existsSync(projectPublicLibPath) && fsPromise.rm(projectPublicLibPath, { recursive: true }),
795
- fs.existsSync(projectAssetsLibPath) && fsPromise.rm(projectAssetsLibPath, { recursive: true })
796
- ]);
797
- const targetPublicDeps = libDeps.filter(
798
- (dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/public`)
799
- );
800
- const targetAssetsDeps = libDeps.filter(
801
- (dep) => fs.existsSync(`${this.workspace.workspaceRoot}/libs/${dep}/assets`)
802
- );
803
- await Promise.all([
804
- ...targetPublicDeps.map((dep) => fsPromise.mkdir(`${projectPublicLibPath}/${dep}`, { recursive: true })),
805
- ...targetAssetsDeps.map((dep) => fsPromise.mkdir(`${projectAssetsLibPath}/${dep}`, { recursive: true }))
800
+ ...targetPublicDeps.map((dep) => this.mkdir(`${projectPublicLibPath}/${dep}`)),
801
+ ...targetAssetsDeps.map((dep) => this.mkdir(`${projectAssetsLibPath}/${dep}`))
806
802
  ]);
807
803
  await Promise.all([
808
804
  ...targetPublicDeps.map(
809
- (dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`, {
810
- recursive: true
811
- })
805
+ (dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`)
812
806
  ),
813
807
  ...targetAssetsDeps.map(
814
- (dep) => fsPromise.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`, {
815
- recursive: true
816
- })
808
+ (dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/assets`, `${projectAssetsLibPath}/${dep}`)
817
809
  )
818
810
  ]);
819
811
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "0.9.55",
3
+ "version": "0.9.57",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -40,7 +40,7 @@ export declare class Executor {
40
40
  }>;
41
41
  exists(filePath: string): boolean;
42
42
  remove(filePath: string): this;
43
- removeDir(dirPath: string): this;
43
+ removeDir(dirPath: string): Promise<this>;
44
44
  writeFile(filePath: string, content: string | object, { overwrite }?: {
45
45
  overwrite?: boolean;
46
46
  }): FileContent;