create-astrale-domain 0.2.5 → 0.2.7
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 +48 -24
- 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}.`);
|
|
@@ -933,26 +967,16 @@ function rewriteAstraleDeps(pkg, link) {
|
|
|
933
967
|
}
|
|
934
968
|
return changed;
|
|
935
969
|
}
|
|
970
|
+
var FIRST_PARTY_SCOPES = ["@astrale-domains/*", "@astrale-os/*"];
|
|
936
971
|
async function writeReleaseAgePolicy(dir) {
|
|
937
972
|
const workspace = join(dir, "pnpm-workspace.yaml");
|
|
938
973
|
if (!existsSync(workspace)) return;
|
|
939
|
-
const
|
|
940
|
-
for (const pkgPath of [join(dir, "package.json"), join(dir, "client", "package.json")]) {
|
|
941
|
-
if (!existsSync(pkgPath)) continue;
|
|
942
|
-
const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
943
|
-
for (const group of [pkg.dependencies, pkg.devDependencies]) {
|
|
944
|
-
for (const [name, spec] of Object.entries(group ?? {})) {
|
|
945
|
-
if (name.startsWith("@astrale-os/") && !spec.startsWith("link:")) names.add(name);
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
if (names.size === 0) return;
|
|
950
|
-
const start = "# create-astrale-domain: exact first-party deps";
|
|
974
|
+
const start = "# create-astrale-domain: first-party scopes";
|
|
951
975
|
const end = "# /create-astrale-domain";
|
|
952
976
|
const block = `
|
|
953
977
|
${start}
|
|
954
978
|
minimumReleaseAgeExclude:
|
|
955
|
-
` +
|
|
979
|
+
` + FIRST_PARTY_SCOPES.map((scope) => ` - '${scope}'`).join("\n") + `
|
|
956
980
|
${end}
|
|
957
981
|
`;
|
|
958
982
|
const text = await readFile(workspace, "utf-8");
|
|
@@ -1105,7 +1129,7 @@ async function main() {
|
|
|
1105
1129
|
s.stop(`Created ${dir}`);
|
|
1106
1130
|
} catch (err) {
|
|
1107
1131
|
s.stop("Scaffold failed");
|
|
1108
|
-
xe(err
|
|
1132
|
+
xe(errorReport(err));
|
|
1109
1133
|
return 1;
|
|
1110
1134
|
}
|
|
1111
1135
|
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.7",
|
|
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.4"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@astrale-os/ox": ">=0.1.0 <1.0.0",
|