akanjs 2.0.1 → 2.0.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.
@@ -36,12 +36,10 @@ export class ApplicationRunner extends runner("application") {
36
36
  dict: { appName, companyName: workspace.repoName, startDomain: "localhost" },
37
37
  options: { libs },
38
38
  });
39
- await workspace.setTsPaths("app", appName);
40
39
  return AppExecutor.from(workspace, appName);
41
40
  }
42
41
  async removeApplication(app: App) {
43
42
  await app.workspace.exec(`rm -rf apps/${app.name}`);
44
- await app.workspace.unsetTsPaths("app", app.name);
45
43
  }
46
44
  async getConfig(app: App) {
47
45
  return await app.getConfig();
package/cli/index.js CHANGED
@@ -2827,28 +2827,24 @@ class WorkspaceExecutor extends Executor {
2827
2827
  const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
2828
2828
  return [appNames, libNames, pkgNames];
2829
2829
  }
2830
- async setTsPaths(type, name) {
2830
+ async setPkgTsPaths(name) {
2831
2831
  const rootTsConfig = await this.readJson("tsconfig.json");
2832
2832
  rootTsConfig.compilerOptions.paths ??= {};
2833
- if (type === "lib" || type === "pkg")
2834
- rootTsConfig.compilerOptions.paths[`@${name}`] = [`${type}s/${name}/index.ts`];
2835
- rootTsConfig.compilerOptions.paths[`@${name}/*`] = [`${type}s/${name}/*`];
2836
- rootTsConfig.compilerOptions.paths[`@${type}s/${name}/*`] = [`${type}s/${name}/*`];
2837
- if (type === "lib" || type === "pkg")
2838
- rootTsConfig.compilerOptions.paths[`@${type}s/${name}`] = [`${type}s/${name}/index.ts`];
2833
+ rootTsConfig.compilerOptions.paths[name] = [`./pkgs/${name}/index.ts`];
2834
+ rootTsConfig.compilerOptions.paths[`${name}/*`] = [`./pkgs/${name}/*`];
2839
2835
  if (rootTsConfig.references) {
2840
- if (!rootTsConfig.references.some((ref) => ref.path === `./${type}s/${name}/tsconfig.json`))
2841
- rootTsConfig.references.push({ path: `./${type}s/${name}/tsconfig.json` });
2836
+ if (!rootTsConfig.references.some((ref) => ref.path === `./pkgs/${name}/tsconfig.json`))
2837
+ rootTsConfig.references.push({ path: `./pkgs/${name}/tsconfig.json` });
2842
2838
  }
2843
2839
  await this.writeJson("tsconfig.json", rootTsConfig);
2844
2840
  return this;
2845
2841
  }
2846
- async unsetTsPaths(type, name) {
2842
+ async unsetPkgTsPaths(name) {
2847
2843
  const rootTsConfig = await this.readJson("tsconfig.json");
2848
- const filteredKeys = Object.keys(rootTsConfig.compilerOptions.paths ?? {}).filter((key) => !key.startsWith(`@${name}`) && !key.startsWith(`@${type}s/${name}`));
2844
+ const filteredKeys = Object.keys(rootTsConfig.compilerOptions.paths ?? {}).filter((key) => key !== name && key !== `${name}/*`);
2849
2845
  rootTsConfig.compilerOptions.paths = Object.fromEntries(filteredKeys.map((key) => [key, rootTsConfig.compilerOptions.paths?.[key] ?? []]));
2850
2846
  if (rootTsConfig.references) {
2851
- rootTsConfig.references = rootTsConfig.references.filter((ref) => !ref.path.startsWith(`./${type}s/${name}`));
2847
+ rootTsConfig.references = rootTsConfig.references.filter((ref) => ref.path !== `./pkgs/${name}/tsconfig.json`);
2852
2848
  }
2853
2849
  await this.writeJson("tsconfig.json", rootTsConfig);
2854
2850
  return this;
@@ -3120,10 +3116,6 @@ class SysExecutor extends Executor {
3120
3116
  await this.scan();
3121
3117
  return fileContents;
3122
3118
  }
3123
- setTsPaths() {
3124
- this.workspace.setTsPaths(this.type, this.name);
3125
- return this;
3126
- }
3127
3119
  }
3128
3120
 
3129
3121
  class AppExecutor extends SysExecutor {
@@ -9341,13 +9333,11 @@ class LibraryRunner extends runner("library") {
9341
9333
  async createLibrary(libName, workspace) {
9342
9334
  await workspace.exec(`mkdir -p libs/${libName}`);
9343
9335
  await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
9344
- await workspace.setTsPaths("lib", libName);
9345
9336
  const lib = LibExecutor.from(workspace, libName);
9346
9337
  return lib;
9347
9338
  }
9348
9339
  async removeLibrary(lib) {
9349
9340
  await lib.workspace.exec(`rm -rf libs/${lib.name}`);
9350
- await lib.workspace.unsetTsPaths("lib", lib.name);
9351
9341
  }
9352
9342
  async#copyInstalledLibrary(workspace, libName) {
9353
9343
  const installedPackageJson = `node_modules/akanjs/libs/${libName}/package.json`;
@@ -9368,7 +9358,6 @@ class LibraryRunner extends runner("library") {
9368
9358
  if (!copiedFromInstalledPackage)
9369
9359
  await this.#copyLibraryFromRepository(workspace, libName);
9370
9360
  await workspace.cp(`libs/${libName}/env/env.server.example.ts`, `libs/${libName}/env/env.server.testing.ts`);
9371
- await workspace.setTsPaths("lib", libName);
9372
9361
  await workspace.commit(`Add ${libName} library`);
9373
9362
  return LibExecutor.from(workspace, libName);
9374
9363
  }
@@ -9449,12 +9438,10 @@ class ApplicationRunner extends runner("application") {
9449
9438
  dict: { appName, companyName: workspace.repoName, startDomain: "localhost" },
9450
9439
  options: { libs }
9451
9440
  });
9452
- await workspace.setTsPaths("app", appName);
9453
9441
  return AppExecutor.from(workspace, appName);
9454
9442
  }
9455
9443
  async removeApplication(app) {
9456
9444
  await app.workspace.exec(`rm -rf apps/${app.name}`);
9457
- await app.workspace.unsetTsPaths("app", app.name);
9458
9445
  }
9459
9446
  async getConfig(app) {
9460
9447
  return await app.getConfig();
@@ -10048,11 +10035,11 @@ class PackageRunner extends runner("package") {
10048
10035
  }
10049
10036
  async createPackage(workspace, pkgName) {
10050
10037
  await workspace.applyTemplate({ basePath: `pkgs/${pkgName}`, template: "pkgRoot", dict: { pkgName } });
10051
- await workspace.setTsPaths("pkg", pkgName);
10038
+ await workspace.setPkgTsPaths(pkgName);
10052
10039
  }
10053
10040
  async removePackage(pkg) {
10054
10041
  await pkg.workspace.exec(`rm -rf pkgs/${pkg.name}`);
10055
- await pkg.workspace.unsetTsPaths("pkg", pkg.name);
10042
+ await pkg.workspace.unsetPkgTsPaths(pkg.name);
10056
10043
  }
10057
10044
  async scanSync(pkg) {
10058
10045
  const scanResult = await pkg.scan();
@@ -5,13 +5,11 @@ export class LibraryRunner extends runner("library") {
5
5
  async createLibrary(libName: string, workspace: Workspace) {
6
6
  await workspace.exec(`mkdir -p libs/${libName}`);
7
7
  await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
8
- await workspace.setTsPaths("lib", libName);
9
8
  const lib = LibExecutor.from(workspace, libName);
10
9
  return lib;
11
10
  }
12
11
  async removeLibrary(lib: Lib) {
13
12
  await lib.workspace.exec(`rm -rf libs/${lib.name}`);
14
- await lib.workspace.unsetTsPaths("lib", lib.name);
15
13
  }
16
14
 
17
15
  async #copyInstalledLibrary(workspace: Workspace, libName: string) {
@@ -32,7 +30,6 @@ export class LibraryRunner extends runner("library") {
32
30
  const copiedFromInstalledPackage = await this.#copyInstalledLibrary(workspace, libName);
33
31
  if (!copiedFromInstalledPackage) await this.#copyLibraryFromRepository(workspace, libName);
34
32
  await workspace.cp(`libs/${libName}/env/env.server.example.ts`, `libs/${libName}/env/env.server.testing.ts`);
35
- await workspace.setTsPaths("lib", libName);
36
33
  await workspace.commit(`Add ${libName} library`);
37
34
  return LibExecutor.from(workspace, libName);
38
35
  }
@@ -23,11 +23,11 @@ export class PackageRunner extends runner("package") {
23
23
  }
24
24
  async createPackage(workspace: Workspace, pkgName: string) {
25
25
  await workspace.applyTemplate({ basePath: `pkgs/${pkgName}`, template: "pkgRoot", dict: { pkgName } });
26
- await workspace.setTsPaths("pkg", pkgName);
26
+ await workspace.setPkgTsPaths(pkgName);
27
27
  }
28
28
  async removePackage(pkg: Pkg) {
29
29
  await pkg.workspace.exec(`rm -rf pkgs/${pkg.name}`);
30
- await pkg.workspace.unsetTsPaths("pkg", pkg.name);
30
+ await pkg.workspace.unsetPkgTsPaths(pkg.name);
31
31
  }
32
32
  async scanSync(pkg: Pkg) {
33
33
  const scanResult = await pkg.scan();
@@ -23,7 +23,7 @@
23
23
  "experimentalDecorators": true,
24
24
  "paths": {
25
25
  "@apps/*": ["./apps/*"],
26
- "@libs/*": ["./libs/*"],
26
+ "@libs/*": ["./libs/*"]
27
27
  }
28
28
  }
29
29
  }
@@ -636,33 +636,29 @@ export class WorkspaceExecutor extends Executor {
636
636
  const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
637
637
  return [appNames, libNames, pkgNames] as [string[], string[], string[]];
638
638
  }
639
- async setTsPaths(type: "app" | "lib" | "pkg", name: string) {
639
+ async setPkgTsPaths(name: string) {
640
640
  const rootTsConfig = (await this.readJson("tsconfig.json")) as TsConfigJson;
641
641
  rootTsConfig.compilerOptions.paths ??= {};
642
- if (type === "lib" || type === "pkg")
643
- rootTsConfig.compilerOptions.paths[`@${name}`] = [`${type}s/${name}/index.ts`];
644
- rootTsConfig.compilerOptions.paths[`@${name}/*`] = [`${type}s/${name}/*`];
645
- rootTsConfig.compilerOptions.paths[`@${type}s/${name}/*`] = [`${type}s/${name}/*`];
646
- if (type === "lib" || type === "pkg")
647
- rootTsConfig.compilerOptions.paths[`@${type}s/${name}`] = [`${type}s/${name}/index.ts`];
642
+ rootTsConfig.compilerOptions.paths[name] = [`./pkgs/${name}/index.ts`];
643
+ rootTsConfig.compilerOptions.paths[`${name}/*`] = [`./pkgs/${name}/*`];
648
644
  if (rootTsConfig.references) {
649
- if (!rootTsConfig.references.some((ref) => ref.path === `./${type}s/${name}/tsconfig.json`))
650
- rootTsConfig.references.push({ path: `./${type}s/${name}/tsconfig.json` });
645
+ if (!rootTsConfig.references.some((ref) => ref.path === `./pkgs/${name}/tsconfig.json`))
646
+ rootTsConfig.references.push({ path: `./pkgs/${name}/tsconfig.json` });
651
647
  }
652
648
  await this.writeJson("tsconfig.json", rootTsConfig);
653
649
  return this;
654
650
  }
655
- async unsetTsPaths(type: "app" | "lib" | "pkg", name: string) {
651
+ async unsetPkgTsPaths(name: string) {
656
652
  const rootTsConfig = (await this.readJson("tsconfig.json")) as TsConfigJson;
657
653
  const filteredKeys = Object.keys(rootTsConfig.compilerOptions.paths ?? {}).filter(
658
- (key) => !key.startsWith(`@${name}`) && !key.startsWith(`@${type}s/${name}`),
654
+ (key) => key !== name && key !== `${name}/*`,
659
655
  );
660
656
  rootTsConfig.compilerOptions.paths = Object.fromEntries(
661
657
  filteredKeys.map((key) => [key, rootTsConfig.compilerOptions.paths?.[key] ?? []]),
662
658
  );
663
659
  if (rootTsConfig.references) {
664
660
  rootTsConfig.references = rootTsConfig.references.filter(
665
- (ref) => !ref.path.startsWith(`./${type}s/${name}`),
661
+ (ref) => ref.path !== `./pkgs/${name}/tsconfig.json`,
666
662
  ) as TsConfigJson["references"];
667
663
  }
668
664
  await this.writeJson("tsconfig.json", rootTsConfig);
@@ -1023,10 +1019,6 @@ export class SysExecutor extends Executor {
1023
1019
  await this.scan();
1024
1020
  return fileContents;
1025
1021
  }
1026
- setTsPaths() {
1027
- this.workspace.setTsPaths(this.type, this.name);
1028
- return this;
1029
- }
1030
1022
  }
1031
1023
 
1032
1024
  interface AppExecutorOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "bin": {