@akanjs/cli 2.1.0-rc.2 → 2.1.0-rc.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.
@@ -5865,9 +5865,9 @@ class CssImportResolver {
5865
5865
  }
5866
5866
  async resolve(id, fromBase) {
5867
5867
  for (const resolve of [
5868
+ () => this.#resolveWithTsconfig(id),
5868
5869
  () => this.#resolveWithBun(id, fromBase),
5869
5870
  () => this.#resolveWithRequire(id, fromBase),
5870
- () => this.#resolveWithTsconfig(id),
5871
5871
  () => this.#resolvePackageStyle(id, fromBase)
5872
5872
  ]) {
5873
5873
  const resolved = await resolve();
@@ -5877,20 +5877,24 @@ class CssImportResolver {
5877
5877
  return null;
5878
5878
  }
5879
5879
  #resolveWithBun(id, fromBase) {
5880
- try {
5881
- const resolved = Bun.resolveSync(id, fromBase);
5882
- return CssImportResolver.isCssFile(resolved) ? resolved : null;
5883
- } catch {
5884
- return null;
5880
+ for (const base of this.#resolutionBases(fromBase)) {
5881
+ try {
5882
+ const resolved = Bun.resolveSync(id, base);
5883
+ if (CssImportResolver.isCssFile(resolved))
5884
+ return resolved;
5885
+ } catch {}
5885
5886
  }
5887
+ return null;
5886
5888
  }
5887
5889
  #resolveWithRequire(id, fromBase) {
5888
- try {
5889
- const resolved = __require.resolve(id, { paths: [fromBase] });
5890
- return CssImportResolver.isCssFile(resolved) ? resolved : null;
5891
- } catch {
5892
- return null;
5890
+ for (const base of this.#resolutionBases(fromBase)) {
5891
+ try {
5892
+ const resolved = __require.resolve(id, { paths: [base] });
5893
+ if (CssImportResolver.isCssFile(resolved))
5894
+ return resolved;
5895
+ } catch {}
5893
5896
  }
5897
+ return null;
5894
5898
  }
5895
5899
  async#resolveWithTsconfig(id) {
5896
5900
  const exact = this.#paths[id];
@@ -5918,8 +5922,25 @@ class CssImportResolver {
5918
5922
  const pkgName = CssImportResolver.getPackageName(id);
5919
5923
  if (!pkgName)
5920
5924
  return null;
5925
+ for (const base of this.#resolutionBases(fromBase)) {
5926
+ try {
5927
+ const pkgPath = __require.resolve(`${pkgName}/package.json`, { paths: [base] });
5928
+ const resolved = await this.#resolvePackageStyleFromPackageJson(id, pkgName, pkgPath);
5929
+ if (resolved)
5930
+ return resolved;
5931
+ } catch {}
5932
+ }
5933
+ for (const pkgPath of this.#packageJsonCandidates(pkgName)) {
5934
+ const resolved = await this.#resolvePackageStyleFromPackageJson(id, pkgName, pkgPath);
5935
+ if (resolved)
5936
+ return resolved;
5937
+ }
5938
+ return null;
5939
+ }
5940
+ async#resolvePackageStyleFromPackageJson(id, pkgName, pkgPath) {
5921
5941
  try {
5922
- const pkgPath = __require.resolve(`${pkgName}/package.json`, { paths: [fromBase] });
5942
+ if (!await Bun.file(pkgPath).exists())
5943
+ return null;
5923
5944
  const pkgDir = path22.dirname(pkgPath);
5924
5945
  const pkg = await Bun.file(pkgPath).json();
5925
5946
  const subpath = id === pkgName ? "." : `.${id.slice(pkgName.length)}`;
@@ -5930,6 +5951,22 @@ class CssImportResolver {
5930
5951
  return null;
5931
5952
  }
5932
5953
  }
5954
+ #resolutionBases(fromBase) {
5955
+ return [
5956
+ fromBase,
5957
+ this.#workspaceRoot,
5958
+ path22.dirname(Bun.main),
5959
+ path22.resolve(path22.dirname(Bun.main), "../..")
5960
+ ];
5961
+ }
5962
+ #packageJsonCandidates(pkgName) {
5963
+ return [
5964
+ path22.join(this.#workspaceRoot, "pkgs", pkgName, "package.json"),
5965
+ path22.join(this.#workspaceRoot, "node_modules", pkgName, "package.json"),
5966
+ path22.join(path22.dirname(Bun.main), "node_modules", pkgName, "package.json"),
5967
+ path22.join(path22.dirname(Bun.main), "../../", pkgName, "package.json")
5968
+ ];
5969
+ }
5933
5970
  async#firstExisting(basePath2) {
5934
5971
  for (const suffix of CSS_IMPORT_EXTS) {
5935
5972
  const candidate = `${basePath2}${suffix}`;
@@ -7054,14 +7091,23 @@ class SsrBaseArtifactBuilder {
7054
7091
  async#resolveAkanServerPath() {
7055
7092
  const candidates = [
7056
7093
  path30.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server"),
7094
+ path30.join(this.#app.workspace.workspaceRoot, "node_modules/akanjs/server"),
7095
+ path30.join(path30.dirname(Bun.main), "node_modules/akanjs/server"),
7096
+ path30.join(path30.dirname(Bun.main), "../../akanjs/server"),
7057
7097
  path30.resolve(import.meta.dir, "../../server"),
7058
7098
  path30.resolve(import.meta.dir, "../server")
7059
7099
  ];
7100
+ try {
7101
+ candidates.unshift(path30.dirname(Bun.resolveSync("akanjs/server", this.#app.workspace.workspaceRoot)));
7102
+ } catch {}
7103
+ try {
7104
+ candidates.unshift(path30.dirname(Bun.resolveSync("akanjs/server", path30.dirname(Bun.main))));
7105
+ } catch {}
7060
7106
  for (const candidate of candidates) {
7061
7107
  if (await Bun.file(path30.join(candidate, "rscClient.tsx")).exists())
7062
7108
  return candidate;
7063
7109
  }
7064
- return candidates[0];
7110
+ throw new Error(`[base-artifact] failed to locate akanjs/server; looked in: ${candidates.join(", ")}`);
7065
7111
  }
7066
7112
  async#buildStyleAssets() {
7067
7113
  const cssCompiler = new CssCompiler(this.#app);
package/index.js CHANGED
@@ -5862,9 +5862,9 @@ class CssImportResolver {
5862
5862
  }
5863
5863
  async resolve(id, fromBase) {
5864
5864
  for (const resolve of [
5865
+ () => this.#resolveWithTsconfig(id),
5865
5866
  () => this.#resolveWithBun(id, fromBase),
5866
5867
  () => this.#resolveWithRequire(id, fromBase),
5867
- () => this.#resolveWithTsconfig(id),
5868
5868
  () => this.#resolvePackageStyle(id, fromBase)
5869
5869
  ]) {
5870
5870
  const resolved = await resolve();
@@ -5874,20 +5874,24 @@ class CssImportResolver {
5874
5874
  return null;
5875
5875
  }
5876
5876
  #resolveWithBun(id, fromBase) {
5877
- try {
5878
- const resolved = Bun.resolveSync(id, fromBase);
5879
- return CssImportResolver.isCssFile(resolved) ? resolved : null;
5880
- } catch {
5881
- return null;
5877
+ for (const base of this.#resolutionBases(fromBase)) {
5878
+ try {
5879
+ const resolved = Bun.resolveSync(id, base);
5880
+ if (CssImportResolver.isCssFile(resolved))
5881
+ return resolved;
5882
+ } catch {}
5882
5883
  }
5884
+ return null;
5883
5885
  }
5884
5886
  #resolveWithRequire(id, fromBase) {
5885
- try {
5886
- const resolved = __require.resolve(id, { paths: [fromBase] });
5887
- return CssImportResolver.isCssFile(resolved) ? resolved : null;
5888
- } catch {
5889
- return null;
5887
+ for (const base of this.#resolutionBases(fromBase)) {
5888
+ try {
5889
+ const resolved = __require.resolve(id, { paths: [base] });
5890
+ if (CssImportResolver.isCssFile(resolved))
5891
+ return resolved;
5892
+ } catch {}
5890
5893
  }
5894
+ return null;
5891
5895
  }
5892
5896
  async#resolveWithTsconfig(id) {
5893
5897
  const exact = this.#paths[id];
@@ -5915,8 +5919,25 @@ class CssImportResolver {
5915
5919
  const pkgName = CssImportResolver.getPackageName(id);
5916
5920
  if (!pkgName)
5917
5921
  return null;
5922
+ for (const base of this.#resolutionBases(fromBase)) {
5923
+ try {
5924
+ const pkgPath = __require.resolve(`${pkgName}/package.json`, { paths: [base] });
5925
+ const resolved = await this.#resolvePackageStyleFromPackageJson(id, pkgName, pkgPath);
5926
+ if (resolved)
5927
+ return resolved;
5928
+ } catch {}
5929
+ }
5930
+ for (const pkgPath of this.#packageJsonCandidates(pkgName)) {
5931
+ const resolved = await this.#resolvePackageStyleFromPackageJson(id, pkgName, pkgPath);
5932
+ if (resolved)
5933
+ return resolved;
5934
+ }
5935
+ return null;
5936
+ }
5937
+ async#resolvePackageStyleFromPackageJson(id, pkgName, pkgPath) {
5918
5938
  try {
5919
- const pkgPath = __require.resolve(`${pkgName}/package.json`, { paths: [fromBase] });
5939
+ if (!await Bun.file(pkgPath).exists())
5940
+ return null;
5920
5941
  const pkgDir = path22.dirname(pkgPath);
5921
5942
  const pkg = await Bun.file(pkgPath).json();
5922
5943
  const subpath = id === pkgName ? "." : `.${id.slice(pkgName.length)}`;
@@ -5927,6 +5948,22 @@ class CssImportResolver {
5927
5948
  return null;
5928
5949
  }
5929
5950
  }
5951
+ #resolutionBases(fromBase) {
5952
+ return [
5953
+ fromBase,
5954
+ this.#workspaceRoot,
5955
+ path22.dirname(Bun.main),
5956
+ path22.resolve(path22.dirname(Bun.main), "../..")
5957
+ ];
5958
+ }
5959
+ #packageJsonCandidates(pkgName) {
5960
+ return [
5961
+ path22.join(this.#workspaceRoot, "pkgs", pkgName, "package.json"),
5962
+ path22.join(this.#workspaceRoot, "node_modules", pkgName, "package.json"),
5963
+ path22.join(path22.dirname(Bun.main), "node_modules", pkgName, "package.json"),
5964
+ path22.join(path22.dirname(Bun.main), "../../", pkgName, "package.json")
5965
+ ];
5966
+ }
5930
5967
  async#firstExisting(basePath2) {
5931
5968
  for (const suffix of CSS_IMPORT_EXTS) {
5932
5969
  const candidate = `${basePath2}${suffix}`;
@@ -7051,14 +7088,23 @@ class SsrBaseArtifactBuilder {
7051
7088
  async#resolveAkanServerPath() {
7052
7089
  const candidates = [
7053
7090
  path30.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server"),
7091
+ path30.join(this.#app.workspace.workspaceRoot, "node_modules/akanjs/server"),
7092
+ path30.join(path30.dirname(Bun.main), "node_modules/akanjs/server"),
7093
+ path30.join(path30.dirname(Bun.main), "../../akanjs/server"),
7054
7094
  path30.resolve(import.meta.dir, "../../server"),
7055
7095
  path30.resolve(import.meta.dir, "../server")
7056
7096
  ];
7097
+ try {
7098
+ candidates.unshift(path30.dirname(Bun.resolveSync("akanjs/server", this.#app.workspace.workspaceRoot)));
7099
+ } catch {}
7100
+ try {
7101
+ candidates.unshift(path30.dirname(Bun.resolveSync("akanjs/server", path30.dirname(Bun.main))));
7102
+ } catch {}
7057
7103
  for (const candidate of candidates) {
7058
7104
  if (await Bun.file(path30.join(candidate, "rscClient.tsx")).exists())
7059
7105
  return candidate;
7060
7106
  }
7061
- return candidates[0];
7107
+ throw new Error(`[base-artifact] failed to locate akanjs/server; looked in: ${candidates.join(", ")}`);
7062
7108
  }
7063
7109
  async#buildStyleAssets() {
7064
7110
  const cssCompiler = new CssCompiler(this.#app);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/cli",
3
- "version": "2.1.0-rc.2",
3
+ "version": "2.1.0-rc.3",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -34,7 +34,7 @@
34
34
  "@langchain/deepseek": "^1.0.26",
35
35
  "@langchain/openai": "^1.4.6",
36
36
  "@trapezedev/project": "^7.1.4",
37
- "akanjs": "2.1.0-rc.1",
37
+ "akanjs": "2.1.0-rc.3",
38
38
  "chalk": "^5.6.2",
39
39
  "commander": "^14.0.3",
40
40
  "fontaine": "^0.8.0",