create-astrale-domain 0.2.5 → 0.2.6
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.
- package/dist/index.js +45 -11
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -804,19 +804,35 @@ var ADAPTER_PACKAGES = {
|
|
|
804
804
|
astrale: "@astrale-os/adapter-astrale",
|
|
805
805
|
cloudflare: "@astrale-os/adapter-cloudflare"
|
|
806
806
|
};
|
|
807
|
-
function
|
|
807
|
+
function resolveModule(id) {
|
|
808
808
|
try {
|
|
809
|
-
return require2.resolve(id);
|
|
810
|
-
} catch {
|
|
811
|
-
return
|
|
809
|
+
return { path: require2.resolve(id) };
|
|
810
|
+
} catch (error) {
|
|
811
|
+
return { error };
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
|
+
function errorText(err) {
|
|
815
|
+
if (err instanceof Error) return err.message;
|
|
816
|
+
return err === void 0 ? "" : String(err);
|
|
817
|
+
}
|
|
818
|
+
function errorReport(err) {
|
|
819
|
+
if (!(err instanceof Error)) return String(err);
|
|
820
|
+
const cause = err.cause;
|
|
821
|
+
if (cause !== void 0) {
|
|
822
|
+
const causeText = cause instanceof Error ? cause.message : String(cause);
|
|
823
|
+
if (causeText && !err.message.includes(causeText)) {
|
|
824
|
+
return `${err.message}
|
|
825
|
+
\u21B3 caused by: ${causeText}`;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
return err.message;
|
|
829
|
+
}
|
|
814
830
|
function packageRoot(pkg) {
|
|
815
|
-
const direct =
|
|
816
|
-
if (direct) return dirname(direct);
|
|
817
|
-
const entry =
|
|
818
|
-
if (entry) {
|
|
819
|
-
let dir = dirname(entry);
|
|
831
|
+
const direct = resolveModule(`${pkg}/package.json`);
|
|
832
|
+
if ("path" in direct) return dirname(direct.path);
|
|
833
|
+
const entry = resolveModule(pkg);
|
|
834
|
+
if ("path" in entry) {
|
|
835
|
+
let dir = dirname(entry.path);
|
|
820
836
|
for (; ; ) {
|
|
821
837
|
const candidate = join(dir, "package.json");
|
|
822
838
|
if (existsSync(candidate)) {
|
|
@@ -830,13 +846,31 @@ function packageRoot(pkg) {
|
|
|
830
846
|
if (parent === dir) break;
|
|
831
847
|
dir = parent;
|
|
832
848
|
}
|
|
849
|
+
throw new Error(
|
|
850
|
+
`Could not locate the ${pkg} package.json (its entry resolved at ${entry.path}, but no ancestor package.json declares "name": "${pkg}").`
|
|
851
|
+
);
|
|
833
852
|
}
|
|
834
|
-
|
|
853
|
+
const reason = errorText(entry.error);
|
|
854
|
+
throw new Error(
|
|
855
|
+
`Could not locate the ${pkg} package \u2014 is it installed? (run your package manager's install)` + (reason ? ` The module resolver failed: ${reason}` : ""),
|
|
856
|
+
entry.error === void 0 ? void 0 : { cause: entry.error }
|
|
857
|
+
);
|
|
835
858
|
}
|
|
836
859
|
function templateDir(pkg) {
|
|
837
860
|
return join(packageRoot(pkg), "template");
|
|
838
861
|
}
|
|
839
862
|
async function scaffold(opts) {
|
|
863
|
+
const preExisting = existsSync(opts.dir);
|
|
864
|
+
try {
|
|
865
|
+
await writeProject(opts);
|
|
866
|
+
} catch (err) {
|
|
867
|
+
if (!preExisting && existsSync(opts.dir)) {
|
|
868
|
+
await rm(opts.dir, { recursive: true, force: true });
|
|
869
|
+
}
|
|
870
|
+
throw err;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
async function writeProject(opts) {
|
|
840
874
|
const src = templateDir(BODY_PACKAGE);
|
|
841
875
|
if (!existsSync(src)) {
|
|
842
876
|
throw new Error(`Template not found at ${src}.`);
|
|
@@ -1105,7 +1139,7 @@ async function main() {
|
|
|
1105
1139
|
s.stop(`Created ${dir}`);
|
|
1106
1140
|
} catch (err) {
|
|
1107
1141
|
s.stop("Scaffold failed");
|
|
1108
|
-
xe(err
|
|
1142
|
+
xe(errorReport(err));
|
|
1109
1143
|
return 1;
|
|
1110
1144
|
}
|
|
1111
1145
|
if (link) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astrale-domain",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Scaffold a standalone Astrale domain — npm create astrale-domain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@clack/prompts": "^0.11.0",
|
|
22
|
-
"@astrale-os/adapter-
|
|
23
|
-
"@astrale-os/adapter-
|
|
22
|
+
"@astrale-os/adapter-astrale": "^0.4.0",
|
|
23
|
+
"@astrale-os/adapter-cloudflare": "^0.4.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@astrale-os/ox": ">=0.1.0 <1.0.0",
|