@akanjs/devkit 0.9.1 → 0.9.3

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.
@@ -456,6 +456,7 @@ class WorkspaceExecutor extends Executor {
456
456
  }
457
457
  setTsPaths(type, name) {
458
458
  const rootTsConfig = this.readJson("tsconfig.json");
459
+ rootTsConfig.compilerOptions.paths ??= {};
459
460
  if (type === "lib" || type === "pkg")
460
461
  rootTsConfig.compilerOptions.paths[`@${name}`] = [`${type}s/${name}/index.ts`];
461
462
  rootTsConfig.compilerOptions.paths[`@${name}/*`] = [`${type}s/${name}/*`];
@@ -468,9 +469,11 @@ class WorkspaceExecutor extends Executor {
468
469
  }
469
470
  unsetTsPaths(type, name) {
470
471
  const rootTsConfig = this.readJson("tsconfig.json");
471
- const filteredKeys = Object.keys(rootTsConfig.compilerOptions.paths).filter((key) => !key.startsWith(`@${name}`));
472
+ const filteredKeys = Object.keys(rootTsConfig.compilerOptions.paths ?? {}).filter(
473
+ (key) => !key.startsWith(`@${name}`)
474
+ );
472
475
  rootTsConfig.compilerOptions.paths = Object.fromEntries(
473
- filteredKeys.map((key) => [key, rootTsConfig.compilerOptions.paths[key]])
476
+ filteredKeys.map((key) => [key, rootTsConfig.compilerOptions.paths?.[key] ?? []])
474
477
  );
475
478
  if (rootTsConfig.references) {
476
479
  rootTsConfig.references = rootTsConfig.references.filter(
@@ -591,19 +594,19 @@ class SysExecutor extends Executor {
591
594
  const scanner = new import_dependencyScanner.TypeScriptDependencyScanner(this.cwdPath);
592
595
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
593
596
  const pkgPathSet = new Set(
594
- Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
597
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path2) => tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
595
598
  );
596
599
  const libPathSet = new Set(
597
- Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("libs/"))).map((path2) => path2.replace("/*", ""))
600
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path2) => tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("libs/"))).map((path2) => path2.replace("/*", ""))
598
601
  );
599
602
  const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
600
603
  const pkgDeps = [...pkgPathDepSet].map((path2) => {
601
604
  const pathSplitLength = path2.split("/").length;
602
- return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
605
+ return (tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
603
606
  });
604
607
  const libDeps = [...libPathDepSet].map((path2) => {
605
608
  const pathSplitLength = path2.split("/").length;
606
- return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
609
+ return (tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
607
610
  }).filter((libName) => libName !== this.name);
608
611
  if (!import_fs.default.existsSync(`${this.cwdPath}/lib/__scalar`))
609
612
  import_fs.default.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
@@ -905,12 +908,12 @@ class PkgExecutor extends Executor {
905
908
  const scanner = new import_dependencyScanner.TypeScriptDependencyScanner(this.cwdPath);
906
909
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
907
910
  const pkgPathSet = new Set(
908
- Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
911
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path2) => tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
909
912
  );
910
913
  const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
911
914
  const pkgDeps = [...pkgPathDepSet].map((path2) => {
912
915
  const pathSplitLength = path2.split("/").length;
913
- return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
916
+ return (tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
914
917
  }).filter((pkg) => pkg !== this.name);
915
918
  const pkgScanResult = {
916
919
  name: this.name,
@@ -421,6 +421,7 @@ class WorkspaceExecutor extends Executor {
421
421
  }
422
422
  setTsPaths(type, name) {
423
423
  const rootTsConfig = this.readJson("tsconfig.json");
424
+ rootTsConfig.compilerOptions.paths ??= {};
424
425
  if (type === "lib" || type === "pkg")
425
426
  rootTsConfig.compilerOptions.paths[`@${name}`] = [`${type}s/${name}/index.ts`];
426
427
  rootTsConfig.compilerOptions.paths[`@${name}/*`] = [`${type}s/${name}/*`];
@@ -433,9 +434,11 @@ class WorkspaceExecutor extends Executor {
433
434
  }
434
435
  unsetTsPaths(type, name) {
435
436
  const rootTsConfig = this.readJson("tsconfig.json");
436
- const filteredKeys = Object.keys(rootTsConfig.compilerOptions.paths).filter((key) => !key.startsWith(`@${name}`));
437
+ const filteredKeys = Object.keys(rootTsConfig.compilerOptions.paths ?? {}).filter(
438
+ (key) => !key.startsWith(`@${name}`)
439
+ );
437
440
  rootTsConfig.compilerOptions.paths = Object.fromEntries(
438
- filteredKeys.map((key) => [key, rootTsConfig.compilerOptions.paths[key]])
441
+ filteredKeys.map((key) => [key, rootTsConfig.compilerOptions.paths?.[key] ?? []])
439
442
  );
440
443
  if (rootTsConfig.references) {
441
444
  rootTsConfig.references = rootTsConfig.references.filter(
@@ -556,19 +559,19 @@ class SysExecutor extends Executor {
556
559
  const scanner = new TypeScriptDependencyScanner(this.cwdPath);
557
560
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
558
561
  const pkgPathSet = new Set(
559
- Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
562
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path2) => tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
560
563
  );
561
564
  const libPathSet = new Set(
562
- Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("libs/"))).map((path2) => path2.replace("/*", ""))
565
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path2) => tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("libs/"))).map((path2) => path2.replace("/*", ""))
563
566
  );
564
567
  const [npmDepSet, pkgPathDepSet, libPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet, libPathSet]);
565
568
  const pkgDeps = [...pkgPathDepSet].map((path2) => {
566
569
  const pathSplitLength = path2.split("/").length;
567
- return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
570
+ return (tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
568
571
  });
569
572
  const libDeps = [...libPathDepSet].map((path2) => {
570
573
  const pathSplitLength = path2.split("/").length;
571
- return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
574
+ return (tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
572
575
  }).filter((libName) => libName !== this.name);
573
576
  if (!fs.existsSync(`${this.cwdPath}/lib/__scalar`))
574
577
  fs.mkdirSync(`${this.cwdPath}/lib/__scalar`, { recursive: true });
@@ -870,12 +873,12 @@ class PkgExecutor extends Executor {
870
873
  const scanner = new TypeScriptDependencyScanner(this.cwdPath);
871
874
  const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
872
875
  const pkgPathSet = new Set(
873
- Object.keys(tsconfig.compilerOptions.paths).filter((path2) => tsconfig.compilerOptions.paths[path2].some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
876
+ Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path2) => tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
874
877
  );
875
878
  const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
876
879
  const pkgDeps = [...pkgPathDepSet].map((path2) => {
877
880
  const pathSplitLength = path2.split("/").length;
878
- return tsconfig.compilerOptions.paths[path2][0].split("/").slice(1, 1 + pathSplitLength).join("/");
881
+ return (tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
879
882
  }).filter((pkg) => pkg !== this.name);
880
883
  const pkgScanResult = {
881
884
  name: this.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -102,7 +102,7 @@ export declare class WorkspaceExecutor extends Executor {
102
102
  getBaseDevEnv(): {
103
103
  repoName: string;
104
104
  serveDomain: string;
105
- env: "debug" | "testing" | "local" | "develop" | "main";
105
+ env: "testing" | "local" | "debug" | "develop" | "main";
106
106
  name?: string | undefined;
107
107
  };
108
108
  scan(): Promise<WorkspaceScanResult>;
@@ -215,7 +215,7 @@ export declare class AppExecutor extends SysExecutor {
215
215
  emoji: string;
216
216
  constructor({ workspace, name }: AppExecutorOptions);
217
217
  static from(executor: SysExecutor | WorkspaceExecutor, name: string): AppExecutor;
218
- getEnv(): "debug" | "testing" | "local" | "develop" | "main";
218
+ getEnv(): "testing" | "local" | "debug" | "develop" | "main";
219
219
  getConfig(command?: string): Promise<AppConfigResult>;
220
220
  syncAssets(libDeps: string[]): Promise<void>;
221
221
  }
package/src/types.d.ts CHANGED
@@ -18,7 +18,7 @@ export interface TsConfigJson {
18
18
  extends?: string;
19
19
  compilerOptions: {
20
20
  target: string;
21
- paths: Record<string, string[]>;
21
+ paths?: Record<string, string[]>;
22
22
  };
23
23
  references?: {
24
24
  path: string;