create-astrale-domain 0.3.0-beta.21 → 0.3.0-beta.211

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.
Files changed (55) hide show
  1. package/README.md +54 -3
  2. package/dist/index.js +382 -135
  3. package/package.json +17 -12
  4. package/template/.env.example +9 -8
  5. package/template/.gitignore.template +8 -2
  6. package/template/.variants/custom/README.md +19 -9
  7. package/template/.variants/custom/__tests__/variant.test.ts +4 -4
  8. package/template/.variants/custom/domain.ts +28 -0
  9. package/template/.variants/custom/{views/application/app → frontend}/index.html +1 -0
  10. package/template/.variants/custom/{views/application/app → frontend}/main.ts +1 -1
  11. package/template/.variants/custom/frontend/package.json +11 -0
  12. package/template/.variants/custom/frontend/public/favicon.svg +4 -0
  13. package/template/.variants/custom/frontend/tsconfig.json +17 -0
  14. package/template/.variants/custom/schema/schema.ts +15 -0
  15. package/template/.variants/custom/views/application/index.ts +1 -0
  16. package/template/.variants/custom/views/index.ts +1 -1
  17. package/template/.variants/custom/vite.config.ts +11 -2
  18. package/template/.variants/none/README.md +13 -4
  19. package/template/.variants/none/__tests__/variant.test.ts +3 -3
  20. package/template/.variants/none/domain.ts +18 -0
  21. package/template/.variants/none/schema/schema.ts +11 -0
  22. package/template/.variants/react/README.md +20 -10
  23. package/template/.variants/react/__tests__/variant.test.ts +4 -4
  24. package/template/.variants/react/domain.ts +28 -0
  25. package/template/.variants/react/frontend/index.html +1 -0
  26. package/template/.variants/react/frontend/package.json +7 -1
  27. package/template/.variants/react/frontend/public/favicon.svg +4 -0
  28. package/template/.variants/react/frontend/src/styles.css +1 -1
  29. package/template/.variants/react/frontend/tsconfig.json +19 -0
  30. package/template/.variants/react/schema/schema.ts +15 -0
  31. package/template/.variants/react/vite.config.ts +2 -3
  32. package/template/CLAUDE.md +43 -5
  33. package/template/index.ts +1 -1
  34. package/template/package.json +15 -31
  35. package/template/pnpm-workspace.yaml +5 -21
  36. package/template/runtime.ts +1 -2
  37. package/template/schema/__tests__/schema.test.ts +14 -0
  38. package/template/schema/index.ts +1 -1
  39. package/template/tests/datasets/demo.ts +21 -0
  40. package/template/tests/e2e/domain.test.ts +9 -0
  41. package/template/tsconfig.json +8 -17
  42. package/template/.variants/custom/application.ts +0 -9
  43. package/template/.variants/custom/schema/application/index.ts +0 -8
  44. package/template/.variants/custom/views/application/__tests__/routes.test.ts +0 -7
  45. package/template/.variants/custom/views/application/routes.ts +0 -12
  46. package/template/.variants/none/application.ts +0 -8
  47. package/template/.variants/none/schema/application/index.ts +0 -5
  48. package/template/.variants/react/application.ts +0 -9
  49. package/template/.variants/react/schema/application/index.ts +0 -8
  50. package/template/.variants/react/views/application/__tests__/routes.test.ts +0 -7
  51. package/template/.variants/react/views/application/routes.ts +0 -12
  52. package/template/.variants/react/views/index.ts +0 -1
  53. package/template/schema/application/__tests__/schema.test.ts +0 -11
  54. package/template/tests/e2e/application.test.ts +0 -10
  55. package/template/tsconfig.package.json +0 -29
package/dist/index.js CHANGED
@@ -781,10 +781,252 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
781
781
 
782
782
  // src/index.ts
783
783
  import { existsSync as existsSync2 } from "node:fs";
784
- import { delimiter, join as join2, relative as relative2, resolve as resolve2 } from "node:path";
784
+ import { relative as relative2, resolve as resolve2 } from "node:path";
785
+
786
+ // ../node_modules/.pnpm/@astrale-os+kernel-dsl@1.0.0-beta.28/node_modules/@astrale-os/kernel-dsl/dist/v1/addressing/patterns.js
787
+ var DOMAIN_ORIGIN_PATTERN = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/u;
788
+ var MEMBER_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_]*$/u;
789
+ var DEPENDENCY_ALIAS_PATTERN = /^[a-z][A-Za-z0-9]*$/u;
790
+ var CORE_SLUG_PATTERN = /^(?=.{1,100}$)[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$/u;
791
+ var DOMAIN_REVISION_PATTERN = /^sha256:[0-9a-f]{64}$/u;
792
+ var DOMAIN_REVISION_FULL_MATCH = "sha256:[0-9a-f]{64}";
793
+ var DOMAIN_ORIGIN_FULL_MATCH = "([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?";
794
+ var MEMBER_NAME_FULL_MATCH = "[A-Za-z][A-Za-z0-9_]*";
795
+ var DEPENDENCY_ALIAS_FULL_MATCH = "[a-z][A-Za-z0-9]*";
796
+ var PROPERTY_KEY_FULL_MATCH = "([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?:class\\.[A-Za-z][A-Za-z0-9_]*\\.property\\.[A-Za-z][A-Za-z0-9_]*";
797
+ var PROPERTY_KEY_PATTERN = new RegExp(`^(?:${PROPERTY_KEY_FULL_MATCH})$`, "u");
798
+ var patterns = Object.freeze({
799
+ coreSlug: CORE_SLUG_PATTERN,
800
+ dependencyAlias: DEPENDENCY_ALIAS_PATTERN,
801
+ dependencyAliasFullMatch: DEPENDENCY_ALIAS_FULL_MATCH,
802
+ memberName: MEMBER_NAME_PATTERN,
803
+ memberNameFullMatch: MEMBER_NAME_FULL_MATCH,
804
+ origin: DOMAIN_ORIGIN_PATTERN,
805
+ originFullMatch: DOMAIN_ORIGIN_FULL_MATCH,
806
+ propertyKey: PROPERTY_KEY_PATTERN,
807
+ propertyKeyFullMatch: PROPERTY_KEY_FULL_MATCH,
808
+ revision: DOMAIN_REVISION_PATTERN,
809
+ revisionFullMatch: DOMAIN_REVISION_FULL_MATCH
810
+ });
811
+
812
+ // ../node_modules/.pnpm/@astrale-os+kernel-dsl@1.0.0-beta.28/node_modules/@astrale-os/kernel-dsl/dist/v1/addressing/definition-ref.js
813
+ var DEFINITION_KINDS = /* @__PURE__ */ new Set([
814
+ "class",
815
+ "function",
816
+ "policy",
817
+ "view",
818
+ "core"
819
+ ]);
820
+ function acceptDefinitionRef(input) {
821
+ return readDefinitionRef(input) ?? invalid(input);
822
+ }
823
+ function invalid(input) {
824
+ throw new TypeError(`Invalid DefinitionRef: ${JSON.stringify(input)}.`);
825
+ }
826
+ function readDefinitionRef(input) {
827
+ if (input === null || typeof input !== "object" || Array.isArray(input))
828
+ return void 0;
829
+ const value = input;
830
+ const keys = Reflect.ownKeys(value);
831
+ if (keys.length !== 3 || !keys.every((key) => key === "origin" || key === "kind" || key === "name")) {
832
+ return void 0;
833
+ }
834
+ const { origin, kind, name } = value;
835
+ if (typeof origin !== "string" || !DOMAIN_ORIGIN_PATTERN.test(origin) || typeof kind !== "string" || !DEFINITION_KINDS.has(kind) || typeof name !== "string" || !definitionNameMatches(kind, name)) {
836
+ return void 0;
837
+ }
838
+ return Object.freeze({ origin, kind, name });
839
+ }
840
+ function definitionNameMatches(kind, name) {
841
+ return kind === "core" ? CORE_SLUG_PATTERN.test(name) : MEMBER_NAME_PATTERN.test(name);
842
+ }
843
+
844
+ // ../node_modules/.pnpm/@astrale-os+kernel-dsl@1.0.0-beta.28/node_modules/@astrale-os/kernel-dsl/dist/v1/addressing/key.js
845
+ var DEFINITION_KEY = /^(?:class|function|policy|view)\.([A-Za-z][A-Za-z0-9_]*)$/u;
846
+ var CORE_KEY = /^core\.((?=.{1,100}$)[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*)$/u;
847
+ var MEMBER_KEY = /^class\.([A-Za-z][A-Za-z0-9_]*)\.(property|method)\.([A-Za-z][A-Za-z0-9_]*)$/u;
848
+ var derived = /* @__PURE__ */ new WeakMap();
849
+ function Key(input) {
850
+ if (typeof input !== "string" || !isCanonicalKey(input)) {
851
+ throw new TypeError(`Invalid Key: ${JSON.stringify(input)}.`);
852
+ }
853
+ return input;
854
+ }
855
+ (function(Key2) {
856
+ function of(ref) {
857
+ const object = typeof ref === "object" && ref !== null;
858
+ const known = object ? derived.get(ref) : void 0;
859
+ if (known !== void 0)
860
+ return known;
861
+ const stable = object && immutable(ref);
862
+ const definition = acceptDefinitionRef(ref);
863
+ const key = Key2(`${definition.origin}:${definition.kind}.${definition.name}`);
864
+ if (stable)
865
+ derived.set(ref, key);
866
+ return key;
867
+ }
868
+ Key2.of = of;
869
+ function origin(input) {
870
+ const admitted = Key2(input);
871
+ return admitted.slice(0, admitted.indexOf(":"));
872
+ }
873
+ Key2.origin = origin;
874
+ function is(input) {
875
+ return typeof input === "string" && isCanonicalKey(input);
876
+ }
877
+ Key2.is = is;
878
+ })(Key || (Key = {}));
879
+ function isCanonicalKey(input) {
880
+ const separator = input.indexOf(":");
881
+ return separator > 0 && separator === input.lastIndexOf(":") && DOMAIN_ORIGIN_PATTERN.test(input.slice(0, separator)) && isCanonicalCoordinate(input.slice(separator + 1));
882
+ }
883
+ function isCanonicalCoordinate(input) {
884
+ return DEFINITION_KEY.test(input) || CORE_KEY.test(input) || MEMBER_KEY.test(input);
885
+ }
886
+ function immutable(ref) {
887
+ return Object.isFrozen(ref) && Reflect.ownKeys(ref).every((key) => "value" in Reflect.getOwnPropertyDescriptor(ref, key));
888
+ }
889
+
890
+ // ../node_modules/.pnpm/@astrale-os+kernel-dsl@1.0.0-beta.28/node_modules/@astrale-os/kernel-dsl/dist/v1/addressing/class-key.js
891
+ function ClassKey(input) {
892
+ if (!ClassKey.is(input)) {
893
+ throw new TypeError(`Invalid canonical ClassKey: ${JSON.stringify(input)}.`);
894
+ }
895
+ return input;
896
+ }
897
+ (function(ClassKey2) {
898
+ function of(ref2) {
899
+ const key = Key.of(ref2);
900
+ if (!key.slice(key.indexOf(":") + 1).startsWith("class.")) {
901
+ throw new TypeError(`Invalid ClassKey coordinate: ${JSON.stringify(ref2)}.`);
902
+ }
903
+ return key;
904
+ }
905
+ ClassKey2.of = of;
906
+ function is(input) {
907
+ if (typeof input !== "string" || !Key.is(input))
908
+ return false;
909
+ const coordinate = input.slice(input.indexOf(":") + 1);
910
+ return coordinate.startsWith("class.") && !coordinate.includes(".property.") && !coordinate.includes(".method.");
911
+ }
912
+ ClassKey2.is = is;
913
+ function ref(input) {
914
+ const admitted = ClassKey2(input);
915
+ const separator = admitted.indexOf(":");
916
+ return acceptDefinitionRef({
917
+ origin: admitted.slice(0, separator),
918
+ kind: "class",
919
+ name: admitted.slice(separator + ":class.".length)
920
+ });
921
+ }
922
+ ClassKey2.ref = ref;
923
+ })(ClassKey || (ClassKey = {}));
924
+
925
+ // ../node_modules/.pnpm/@astrale-os+kernel-dsl@1.0.0-beta.28/node_modules/@astrale-os/kernel-dsl/dist/v1/addressing/method-key.js
926
+ function MethodKey(input) {
927
+ if (!MethodKey.is(input)) {
928
+ throw new TypeError(`Invalid canonical MethodKey: ${JSON.stringify(input)}.`);
929
+ }
930
+ return input;
931
+ }
932
+ (function(MethodKey2) {
933
+ function of(owner, name) {
934
+ const admitted = acceptDefinitionRef(owner);
935
+ if (admitted.kind !== "class" || !MEMBER_NAME_PATTERN.test(name)) {
936
+ throw new TypeError(`Invalid MethodKey address: ${JSON.stringify({ owner, name })}.`);
937
+ }
938
+ return Key(`${admitted.origin}:class.${admitted.name}.method.${name}`);
939
+ }
940
+ MethodKey2.of = of;
941
+ function is(input) {
942
+ if (typeof input !== "string" || !Key.is(input))
943
+ return false;
944
+ const [kind, , member] = input.slice(input.indexOf(":") + 1).split(".");
945
+ return kind === "class" && member === "method";
946
+ }
947
+ MethodKey2.is = is;
948
+ function address(input) {
949
+ const admitted = MethodKey2(input);
950
+ const separator = admitted.indexOf(":");
951
+ const coordinate = admitted.slice(separator + ":class.".length);
952
+ const member = coordinate.indexOf(".method.");
953
+ return Object.freeze({
954
+ kind: "method",
955
+ owner: acceptDefinitionRef({
956
+ origin: admitted.slice(0, separator),
957
+ kind: "class",
958
+ name: coordinate.slice(0, member)
959
+ }),
960
+ name: coordinate.slice(member + ".method.".length)
961
+ });
962
+ }
963
+ MethodKey2.address = address;
964
+ })(MethodKey || (MethodKey = {}));
965
+
966
+ // ../node_modules/.pnpm/@astrale-os+kernel-dsl@1.0.0-beta.28/node_modules/@astrale-os/kernel-dsl/dist/value/limits.js
967
+ var defaultLimits = Object.freeze({
968
+ maxBytes: 16 * 1024 * 1024,
969
+ maxDepth: 64,
970
+ maxMembers: 1e5,
971
+ maxStringBytes: 1024 * 1024
972
+ });
973
+
974
+ // ../node_modules/.pnpm/@astrale-os+kernel-dsl@1.0.0-beta.28/node_modules/@astrale-os/kernel-dsl/dist/value/canonical.js
975
+ var encoder = new TextEncoder();
976
+
977
+ // ../node_modules/.pnpm/@astrale-os+kernel-dsl@1.0.0-beta.28/node_modules/@astrale-os/kernel-dsl/dist/v1/addressing/property-key.js
978
+ function PropertyKey(input) {
979
+ if (!PropertyKey.is(input)) {
980
+ throw new TypeError(`Invalid canonical PropertyKey: ${JSON.stringify(input)}.`);
981
+ }
982
+ return input;
983
+ }
984
+ (function(PropertyKey2) {
985
+ function of(owner, name) {
986
+ const admitted = acceptDefinitionRef(owner);
987
+ if (admitted.kind !== "class" || !MEMBER_NAME_PATTERN.test(name)) {
988
+ throw new TypeError(`Invalid PropertyKey coordinate: ${JSON.stringify({ owner, name })}.`);
989
+ }
990
+ return Key(`${admitted.origin}:class.${admitted.name}.property.${name}`);
991
+ }
992
+ PropertyKey2.of = of;
993
+ function is(input) {
994
+ return typeof input === "string" && Key.is(input) && PROPERTY_KEY_PATTERN.test(input);
995
+ }
996
+ PropertyKey2.is = is;
997
+ function address(input) {
998
+ const admitted = PropertyKey2(input);
999
+ const separator = admitted.indexOf(":");
1000
+ const coordinate = admitted.slice(separator + ":class.".length);
1001
+ const member = coordinate.indexOf(".property.");
1002
+ return Object.freeze({
1003
+ owner: acceptDefinitionRef({
1004
+ origin: admitted.slice(0, separator),
1005
+ kind: "class",
1006
+ name: coordinate.slice(0, member)
1007
+ }),
1008
+ name: coordinate.slice(member + ".property.".length)
1009
+ });
1010
+ }
1011
+ PropertyKey2.address = address;
1012
+ })(PropertyKey || (PropertyKey = {}));
1013
+
1014
+ // src/naming/index.ts
1015
+ var NPM_NAME_MAX = 214;
1016
+ var DNS_NAME_MAX = 253;
1017
+ function isValidOrigin(value) {
1018
+ return value.length <= DNS_NAME_MAX && patterns.origin.test(value);
1019
+ }
1020
+ function deriveOrigin(slug) {
1021
+ return slug.includes(".") ? slug : `${slug}.example.dev`;
1022
+ }
1023
+ function isValidProjectSlug(value) {
1024
+ return value.length <= NPM_NAME_MAX && isValidOrigin(deriveOrigin(value));
1025
+ }
1026
+ var PROJECT_SLUG_RULE = `Use dot-separated labels of lowercase letters, digits and inner dashes (63 characters per label, ${NPM_NAME_MAX} in total) \u2014 e.g. crm, 1crm, crm.example.dev.`;
1027
+ var ORIGIN_RULE = `Use a lowercase dotted domain with valid DNS labels (63 characters per label, ${DNS_NAME_MAX} in total) \u2014 e.g. crm.example.dev.`;
785
1028
 
786
1029
  // src/scaffold/index.ts
787
- import { signingIdentity } from "@astrale-os/adapter-cloudflare/build";
788
1030
  import { existsSync, readFileSync } from "node:fs";
789
1031
  import { cp, readFile, rename, rm, writeFile } from "node:fs/promises";
790
1032
  import { createRequire } from "node:module";
@@ -795,7 +1037,7 @@ var HERE = dirname(fileURLToPath(import.meta.url));
795
1037
  var CREATE_PACKAGE_ROOT = owningPackageRoot(HERE, "create-astrale-domain");
796
1038
  var SDK_ROOT = sdkCheckoutRoot(CREATE_PACKAGE_ROOT);
797
1039
  var ORIGIN_PLACEHOLDER = "astrale-domain.example.dev";
798
- var INSTANCE_PLACEHOLDER = "my-instance-slug";
1040
+ var NAME_PLACEHOLDER = "name: 'Astrale Domain'";
799
1041
  var LINK_PACKAGES = /* @__PURE__ */ new Set([
800
1042
  "@astrale-os/sdk",
801
1043
  "@astrale-os/adapter-cloudflare",
@@ -879,7 +1121,7 @@ function sdkCheckoutRoot(createRoot) {
879
1121
  return void 0;
880
1122
  }
881
1123
  }
882
- function installedPackageRange(pkg) {
1124
+ function installedPackageVersion(pkg) {
883
1125
  const manifestPath = join(packageRoot(pkg), "package.json");
884
1126
  const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
885
1127
  if (typeof manifest.version !== "string") {
@@ -889,9 +1131,16 @@ function installedPackageRange(pkg) {
889
1131
  manifest.version
890
1132
  );
891
1133
  if (!match) {
892
- throw new Error(`Could not derive a compatibility range for ${pkg}@${manifest.version}.`);
1134
+ throw new Error(`Could not read an exact version for ${pkg}@${manifest.version}.`);
893
1135
  }
894
- return `>=${manifest.version} <${Number(match[1]) + 1}.0.0`;
1136
+ return manifest.version;
1137
+ }
1138
+ function packageManagerScript(manager, script, argument) {
1139
+ const suffix = argument === void 0 ? "" : ` ${argument}`;
1140
+ if (manager === "npm") return `npm run ${script}${argument === void 0 ? "" : ` --${suffix}`}`;
1141
+ if (manager === "bun") return `bun run ${script}${argument === void 0 ? "" : ` --${suffix}`}`;
1142
+ if (manager === "pnpm" && script === "deploy") return `pnpm run ${script}${suffix}`;
1143
+ return `${manager} ${script}${suffix}`;
895
1144
  }
896
1145
  function templateDir(pkg) {
897
1146
  return join(packageRoot(pkg), "template");
@@ -929,16 +1178,21 @@ async function writeProject(opts) {
929
1178
  await materializeGitignores(opts.dir, opts.frontend);
930
1179
  await materializeAdapter(opts);
931
1180
  await stampOrigin(opts.dir, opts.origin);
932
- await rewritePackageJson(opts.dir, opts.name, opts.link);
933
- if (opts.link) await writeLinkedZodOverride(opts.dir);
934
- await signingIdentity({
935
- projectDir: opts.dir,
936
- origin: opts.origin,
937
- mode: "local"
938
- });
1181
+ await stampName(opts.dir, opts.name);
1182
+ await rewritePackageJson(
1183
+ opts.dir,
1184
+ opts.name,
1185
+ opts.link,
1186
+ opts.packageManager ?? "pnpm",
1187
+ opts.frontend
1188
+ );
1189
+ if (opts.packageManager !== void 0 && opts.packageManager !== "pnpm") {
1190
+ await rm(join(opts.dir, "pnpm-workspace.yaml"), { force: true });
1191
+ }
1192
+ await materializePackageManagerInstructions(opts.dir, opts.packageManager ?? "pnpm");
939
1193
  await writeFile(
940
1194
  join(opts.dir, ".env.dev"),
941
- "# Dev secrets \u2014 the ENTIRE file is injected into the local runtime by `pnpm dev`.\n# Gitignored. See .env.example.\n"
1195
+ "# Development secrets \u2014 `astrale-domain deploy development` binds the ENTIRE file to the\n# deployment it makes. Gitignored. See .env.example.\n"
942
1196
  );
943
1197
  }
944
1198
  async function materializeGitignores(dir, frontend) {
@@ -965,14 +1219,14 @@ async function materializeFrontend(opts, template) {
965
1219
  pkg.devDependencies ??= {};
966
1220
  pkg.scripts ??= {};
967
1221
  if (opts.frontend === "react") {
968
- Object.assign(pkg.dependencies, {
969
- "@tanstack/react-router": "1.170.17",
1222
+ Object.assign(pkg.devDependencies, {
1223
+ "@tanstack/react-router": "1.170.18",
970
1224
  react: "^19.2.0",
971
1225
  "react-dom": "^19.2.0"
972
1226
  });
973
1227
  Object.assign(pkg.devDependencies, {
974
1228
  "@tailwindcss/vite": "^4.0.6",
975
- "@tanstack/router-plugin": "1.168.19",
1229
+ "@tanstack/router-plugin": "1.168.23",
976
1230
  "@types/react": "^19.2.0",
977
1231
  "@types/react-dom": "^19.2.0",
978
1232
  "@vitejs/plugin-react": "^6.0.5",
@@ -1005,63 +1259,122 @@ function assertSafeToDelete(dir) {
1005
1259
  }
1006
1260
  }
1007
1261
  async function stampOrigin(dir, origin) {
1008
- const schemaIndex = join(dir, "schema", "application", "index.ts");
1009
- await replaceInFile(schemaIndex, ORIGIN_PLACEHOLDER, origin);
1010
- const config = join(dir, "astrale.config.ts");
1011
- await replaceInFile(config, ORIGIN_PLACEHOLDER, origin);
1262
+ await replaceInFile(join(dir, "schema", "schema.ts"), ORIGIN_PLACEHOLDER, origin);
1263
+ }
1264
+ async function stampName(dir, packageName) {
1265
+ const name = packageName.slice(packageName.lastIndexOf("/") + 1);
1266
+ await replaceInFile(
1267
+ join(dir, "schema", "schema.ts"),
1268
+ NAME_PLACEHOLDER,
1269
+ `name: ${JSON.stringify(name)}`
1270
+ );
1012
1271
  }
1013
1272
  async function materializeAdapter(opts) {
1014
1273
  const config = join(opts.dir, "astrale.config.ts");
1015
1274
  await cp(join(templateDir(ADAPTER_PACKAGES[opts.adapter]), "astrale.config.ts"), config);
1016
- if (opts.adapter === "cloudflare") return;
1017
- await addManagedAdapterDep(opts.dir);
1018
- if (opts.instance) await replaceInFile(config, `'${INSTANCE_PLACEHOLDER}'`, `'${opts.instance}'`);
1275
+ await addAdapterDependency(opts.dir, ADAPTER_PACKAGES[opts.adapter]);
1019
1276
  }
1020
- async function addManagedAdapterDep(dir) {
1277
+ async function addAdapterDependency(dir, adapter) {
1021
1278
  const path = join(dir, "package.json");
1022
1279
  const pkg = JSON.parse(await readFile(path, "utf-8"));
1023
- if (!pkg.devDependencies || !("@astrale-os/adapter-cloudflare" in pkg.devDependencies)) {
1024
- throw new Error(
1025
- "Could not materialize @astrale-os/adapter-astrale: the scaffold body does not declare its @astrale-os/adapter-cloudflare Worker runtime dependency."
1026
- );
1027
- }
1028
- pkg.devDependencies["@astrale-os/adapter-astrale"] = installedPackageRange(
1029
- "@astrale-os/adapter-astrale"
1030
- );
1280
+ pkg.devDependencies ??= {};
1281
+ pkg.devDependencies[adapter] = installedPackageVersion(adapter);
1031
1282
  pkg.devDependencies = Object.fromEntries(
1032
1283
  Object.entries(pkg.devDependencies).sort(([a], [b3]) => a.localeCompare(b3))
1033
1284
  );
1034
1285
  await writeFile(path, JSON.stringify(pkg, null, 2) + "\n");
1035
1286
  }
1036
- async function rewritePackageJson(dir, name, link) {
1287
+ var PACKAGE_MANAGER_VERSIONS = {
1288
+ // Keep pnpm inside the scaffold's own seven-day release quarantine. Newer
1289
+ // 12.x releases cannot install themselves while minimumReleaseAge is strict.
1290
+ pnpm: "pnpm@12.1.0",
1291
+ npm: "npm@11.19.1",
1292
+ yarn: "yarn@4.18.0",
1293
+ bun: "bun@1.4.4"
1294
+ };
1295
+ var PREPACK_COMMANDS = {
1296
+ pnpm: "pnpm run package",
1297
+ npm: "npm run package",
1298
+ yarn: "yarn package",
1299
+ bun: "bun run package"
1300
+ };
1301
+ var YARN_CONFIGURATION = `nodeLinker: node-modules
1302
+ enableScripts: false
1303
+ npmMinimalAgeGate: 1w
1304
+ npmPreapprovedPackages:
1305
+ - '@astrale-os/*'
1306
+ - '@astrale-domains/*'
1307
+ - '@astrale/*'
1308
+ - '@jsr/astrale__*'
1309
+ - create-astrale-domain
1310
+ `;
1311
+ async function materializePackageManagerInstructions(dir, packageManager) {
1312
+ if (packageManager === "yarn") {
1313
+ await writeFile(join(dir, ".yarnrc.yml"), YARN_CONFIGURATION);
1314
+ }
1315
+ const replacements = [
1316
+ ["pnpm run deploy production", packageManagerScript(packageManager, "deploy", "production")],
1317
+ ["pnpm run deploy development", packageManagerScript(packageManager, "deploy", "development")],
1318
+ ["pnpm deploy production", packageManagerScript(packageManager, "deploy", "production")],
1319
+ ["pnpm build", packageManagerScript(packageManager, "build")],
1320
+ ["pnpm pack", packageManager === "bun" ? "bun pm pack" : `${packageManager} pack`]
1321
+ ];
1322
+ for (const file of ["README.md", "CLAUDE.md", "astrale.config.ts"]) {
1323
+ const target = join(dir, file);
1324
+ if (!existsSync(target)) continue;
1325
+ let content = await readFile(target, "utf8");
1326
+ for (const [from, to] of replacements) content = content.replaceAll(from, to);
1327
+ await writeFile(target, content);
1328
+ }
1329
+ }
1330
+ async function rewritePackageJson(dir, name, link, packageManager, frontend) {
1037
1331
  const path = join(dir, "package.json");
1038
1332
  const pkg = JSON.parse(await readFile(path, "utf-8"));
1039
1333
  pkg.name = name;
1334
+ pkg.packageManager = PACKAGE_MANAGER_VERSIONS[packageManager];
1335
+ if (packageManager === "yarn") {
1336
+ pkg.dependenciesMeta = {
1337
+ ...Object.fromEntries(
1338
+ (pkg.trustedDependencies ?? []).map((dependency) => [dependency, { built: true }])
1339
+ ),
1340
+ // Optional native acceleration; retain the portable JavaScript fallback.
1341
+ "msgpackr-extract": { built: false }
1342
+ };
1343
+ }
1344
+ if (pkg.scripts !== void 0) pkg.scripts.prepack = PREPACK_COMMANDS[packageManager];
1345
+ if (packageManager === "pnpm" || frontend === "none") delete pkg.workspaces;
1346
+ else pkg.workspaces = ["frontend"];
1040
1347
  if (pkg.imports !== void 0) {
1041
1348
  pkg.publishConfig ??= {};
1042
1349
  pkg.publishConfig.imports = publishedImports(pkg.imports);
1043
1350
  }
1044
- rewriteAstraleDeps(pkg, link);
1351
+ if (pkg.dependencies?.["@astrale-os/sdk"] === void 0) {
1352
+ throw new Error("Template is missing the required @astrale-os/sdk dependency.");
1353
+ }
1354
+ pkg.dependencies["@astrale-os/sdk"] = installedPackageVersion("@astrale-os/sdk");
1355
+ rewriteAstraleDeps(pkg, link, packageManager);
1045
1356
  await writeFile(path, JSON.stringify(pkg, null, 2) + "\n");
1046
1357
  }
1047
1358
  function publishedImports(imports) {
1048
1359
  return Object.fromEntries(
1049
- Object.entries(imports).map(([specifier, target]) => {
1360
+ Object.entries(imports).filter(([specifier]) => specifier === "#schema" || specifier === "#schema/*").map(([specifier, target]) => {
1050
1361
  if (!/^\.\/.*\.ts$/u.test(target)) {
1051
- throw new TypeError(`Package import ${specifier} must target one project TypeScript file.`);
1362
+ throw new TypeError(
1363
+ `Package import ${specifier} must target one project TypeScript file.`
1364
+ );
1052
1365
  }
1053
1366
  return [specifier, `./dist/${target.slice(2, -3)}.js`];
1054
1367
  })
1055
1368
  );
1056
1369
  }
1057
- function rewriteAstraleDeps(pkg, link) {
1370
+ function rewriteAstraleDeps(pkg, link, packageManager = "pnpm") {
1058
1371
  if (!link) return false;
1059
1372
  let changed = false;
1060
1373
  for (const group of [pkg.dependencies, pkg.devDependencies]) {
1061
1374
  if (!group) continue;
1062
1375
  for (const dep of Object.keys(group)) {
1063
1376
  if (!LINK_PACKAGES.has(dep)) continue;
1064
- const next = `link:${localPackageRoot(dep)}`;
1377
+ const next = `${packageManager === "pnpm" ? "link" : "file"}:${localPackageRoot(dep)}`;
1065
1378
  if (group[dep] !== next) {
1066
1379
  group[dep] = next;
1067
1380
  changed = true;
@@ -1070,30 +1383,6 @@ function rewriteAstraleDeps(pkg, link) {
1070
1383
  }
1071
1384
  return changed;
1072
1385
  }
1073
- async function writeLinkedZodOverride(dir) {
1074
- const workspace = join(dir, "pnpm-workspace.yaml");
1075
- if (!existsSync(workspace)) return;
1076
- const start = "# create-astrale-domain: linked overrides";
1077
- const end = "# /create-astrale-domain";
1078
- const block = `
1079
- ${start}
1080
- overrides:
1081
- zod: ${sdkZodVersion()}
1082
- ${end}
1083
- `;
1084
- const text = await readFile(workspace, "utf-8");
1085
- const pattern = new RegExp(`\\n?${escapeRegExp(start)}[\\s\\S]*?${escapeRegExp(end)}\\n?`);
1086
- await writeFile(workspace, text.replace(pattern, "\n").trimEnd() + block);
1087
- }
1088
- function escapeRegExp(value) {
1089
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1090
- }
1091
- function sdkZodVersion() {
1092
- if (SDK_ROOT === void 0) throw new Error("Local SDK checkout is unavailable.");
1093
- const sdkRequire = createRequire(join(SDK_ROOT, "package.json"));
1094
- const pkg = sdkRequire("zod/package.json");
1095
- return pkg.version;
1096
- }
1097
1386
  async function replaceInFile(path, from, to) {
1098
1387
  if (!existsSync(path)) return;
1099
1388
  const text = await readFile(path, "utf-8");
@@ -1124,23 +1413,17 @@ function localPackageRoot(dependency) {
1124
1413
 
1125
1414
  // src/index.ts
1126
1415
  var PMS = ["pnpm", "npm", "yarn", "bun"];
1127
- var DLX = {
1128
- pnpm: "pnpm dlx",
1129
- npm: "npx",
1130
- yarn: "yarn dlx",
1131
- bun: "bunx"
1132
- };
1133
1416
  var ADAPTERS = [
1134
1417
  {
1135
1418
  value: "astrale",
1136
1419
  label: "Astrale managed",
1137
- hint: "publishes through the platform onto your instance \u2014 no Cloudflare account",
1420
+ hint: "deploys on Admin's Services \u2014 no Cloudflare account",
1138
1421
  enabled: true
1139
1422
  },
1140
1423
  {
1141
1424
  value: "cloudflare",
1142
- label: "Cloudflare Worker",
1143
- hint: "your own CF account (*.workers.dev / custom domain)",
1425
+ label: "Cloudflare platform namespace",
1426
+ hint: "the platform's dispatch namespace \u2014 platform publishers only",
1144
1427
  enabled: true
1145
1428
  },
1146
1429
  { value: "custom", label: "Custom", hint: "bring your own adapter (soon)", enabled: false }
@@ -1149,7 +1432,7 @@ var FRONTENDS = [
1149
1432
  {
1150
1433
  value: "react",
1151
1434
  label: "React",
1152
- hint: "managed shell integration with typed View component coordinates"
1435
+ hint: "Vite React application with TanStack Router; Shell integration is optional"
1153
1436
  },
1154
1437
  {
1155
1438
  value: "custom",
@@ -1184,13 +1467,18 @@ async function main() {
1184
1467
  const answer = await he({
1185
1468
  message: "Domain name (slug)",
1186
1469
  placeholder: "crm",
1187
- validate: (v2) => isValidSlug(v2) ? void 0 : "Use lowercase letters, digits, dots and dashes."
1470
+ validate: (v2) => isValidProjectSlug(v2) ? void 0 : PROJECT_SLUG_RULE
1188
1471
  });
1189
1472
  if (pD(answer)) return bail();
1190
1473
  slug = answer;
1191
1474
  }
1192
- if (!isValidSlug(slug)) {
1193
- xe(`Invalid slug "${slug}". Use lowercase letters, digits, dots and dashes.`);
1475
+ if (!isValidProjectSlug(slug)) {
1476
+ xe(`Invalid slug "${slug}". ${PROJECT_SLUG_RULE}`);
1477
+ return 1;
1478
+ }
1479
+ const origin = flags.origin ?? deriveOrigin(slug);
1480
+ if (!isValidOrigin(origin)) {
1481
+ xe(`Invalid --origin "${origin}". ${ORIGIN_RULE}`);
1194
1482
  return 1;
1195
1483
  }
1196
1484
  let adapter = flags.adapter;
@@ -1231,16 +1519,11 @@ async function main() {
1231
1519
  xe(`Unknown frontend "${frontend}" \u2014 use "react", "custom", or "none".`);
1232
1520
  return 1;
1233
1521
  }
1234
- const instance = flags.instance;
1235
- if (instance !== void 0 && !isValidSlug(instance)) {
1236
- xe(`Invalid --instance "${instance}". Use lowercase letters, digits, dots and dashes.`);
1237
- return 1;
1238
- }
1239
1522
  let pm = flags.pm;
1240
1523
  if (!pm) {
1241
- const detected = detectPm();
1242
1524
  if (headless) pm = "pnpm";
1243
1525
  else {
1526
+ const detected = detectPm();
1244
1527
  const answer = await ve({
1245
1528
  message: "Package manager",
1246
1529
  initialValue: detected ?? "pnpm",
@@ -1264,13 +1547,6 @@ async function main() {
1264
1547
  if (pD(go) || !go) return bail();
1265
1548
  }
1266
1549
  const link = flags.link ?? workspaceAvailable();
1267
- if (flags.origin !== void 0 && !isValidOrigin(flags.origin)) {
1268
- xe(
1269
- `Invalid --origin "${flags.origin}". Use a lowercase dotted domain with valid DNS labels.`
1270
- );
1271
- return 1;
1272
- }
1273
- const origin = flags.origin ?? (slug.includes(".") ? slug : `${slug}.example.dev`);
1274
1550
  const s = Y2();
1275
1551
  s.start(`Creating ./${slug}`);
1276
1552
  try {
@@ -1280,7 +1556,7 @@ async function main() {
1280
1556
  origin,
1281
1557
  adapter,
1282
1558
  frontend,
1283
- instance,
1559
+ packageManager: pm,
1284
1560
  link
1285
1561
  });
1286
1562
  s.stop(`Created ${dir}`);
@@ -1295,50 +1571,28 @@ async function main() {
1295
1571
  const rel = relative2(process.cwd(), dir);
1296
1572
  const cdTarget = rel && !rel.startsWith("..") ? rel : dir;
1297
1573
  Me(
1298
- [
1299
- `cd ${cdTarget}`,
1300
- `${pm} install`,
1301
- devStep(pm),
1302
- installStep(pm),
1303
- prodStep(pm, adapter, instance)
1304
- ].join("\n"),
1574
+ [`cd ${cdTarget}`, `${pm} install`, ...deploySteps(pm, adapter)].join("\n"),
1305
1575
  "Next"
1306
1576
  );
1307
- if (adapter === "astrale" && !instance) {
1308
- M2.warn(
1309
- `No target instance set \u2014 put your slug in astrale.config.ts (prod.instance) before \`${pm === "npm" ? "npm run prod" : `${pm} prod`}\`. Create one: astrale instance create <slug>`
1310
- );
1311
- }
1312
1577
  M2.info(
1313
1578
  "AI agent on this project? Install the authoring + ops skills once (user-level):\n npx skills add astrale-os/cli -g # or run `astrale setup`"
1314
1579
  );
1315
1580
  Se(`\u2713 ${slug} ready`);
1316
1581
  return 0;
1317
1582
  }
1318
- var devStep = (pm) => `${pm === "npm" ? "npm run dev" : `${pm} dev`} # wrangler dev \u2192 prints a local URL`;
1319
- var prodStep = (pm, adapter, instance) => {
1320
- const cmd = pm === "npm" ? "npm run prod" : `${pm} prod`;
1321
- const hint = adapter === "astrale" ? `# managed deploy \u2192 installs on ${instance ? `"${instance}"` : "your instance"}` : "# deploy prod \u2192 prints a URL";
1322
- return `${cmd} ${hint}`;
1583
+ var DEPLOYMENT_HOSTS = {
1584
+ astrale: "Admin's Services",
1585
+ cloudflare: "the platform's dispatch namespace"
1323
1586
  };
1324
- function installStep(pm) {
1325
- if (astraleOnPath()) return "astrale domain install <url> --direct # mount it on an instance";
1326
- return [
1327
- "# astrale CLI not found on PATH \u2014 run it on demand (no install):",
1328
- `${DLX[pm]} @astrale-os/cli domain install <url> --direct`,
1329
- "# or install it globally: npm i -g @astrale-os/cli"
1330
- ].join("\n");
1331
- }
1332
- function astraleOnPath() {
1333
- const path = process.env.PATH;
1334
- if (!path) return false;
1335
- const names = process.platform === "win32" ? ["astrale.cmd", "astrale.exe", "astrale.bat", "astrale"] : ["astrale"];
1336
- return path.split(delimiter).some((d3) => d3.length > 0 && names.some((n) => existsSync2(join2(d3, n))));
1337
- }
1587
+ var deploySteps = (pm, adapter) => [
1588
+ `${packageManagerScript(pm, "deploy", "development")} # immutable deployment on ${DEPLOYMENT_HOSTS[adapter]} \u2192 prints its URL`,
1589
+ "astrale domain install <url> -i <instance> # install that URL"
1590
+ ];
1338
1591
  function detectPm() {
1339
1592
  const name = process.env.npm_config_user_agent?.split("/")[0];
1340
1593
  return PMS.find((p2) => p2 === name);
1341
1594
  }
1595
+ var INSTANCE_REMOVED = "--instance was removed: a scaffolded Environment names no instance. Deploy, then install the URL the deploy prints with `astrale domain install <url> -i <instance>`.";
1342
1596
  function parseFlags(argv) {
1343
1597
  const flags = { positional: [], force: false, yes: false, help: false };
1344
1598
  for (let i = 0; i < argv.length; i++) {
@@ -1353,9 +1607,10 @@ function parseFlags(argv) {
1353
1607
  else if (a === "--pm") flags.pm = flagValue(argv, ++i, a);
1354
1608
  else if (a === "--dir") flags.dir = flagValue(argv, ++i, a);
1355
1609
  else if (a === "--origin") flags.origin = flagValue(argv, ++i, a);
1356
- else if (a === "--instance") flags.instance = flagValue(argv, ++i, a);
1610
+ else if (a === "--instance" || a.startsWith("--instance="))
1611
+ throw new TypeError(INSTANCE_REMOVED);
1357
1612
  else if (a.startsWith("-")) throw new TypeError(`Unknown option "${a}".`);
1358
- else if (!a.startsWith("-")) flags.positional.push(a);
1613
+ else flags.positional.push(a);
1359
1614
  }
1360
1615
  return flags;
1361
1616
  }
@@ -1376,12 +1631,13 @@ Usage:
1376
1631
  pnpm create astrale-domain <slug> [options]
1377
1632
 
1378
1633
  Arguments:
1379
- <slug> domain name (lowercase letters, digits, dots, dashes)
1634
+ <slug> domain name \u2014 dot-separated labels of lowercase letters,
1635
+ digits and inner dashes (crm \xB7 1crm \xB7 crm.example.dev)
1380
1636
 
1381
1637
  Options:
1382
- --adapter <id> deployment adapter \u2014 astrale (managed, default) | cloudflare
1638
+ --adapter <id> deployment adapter \u2014 astrale (managed, default)
1639
+ | cloudflare (platform dispatch namespace)
1383
1640
  --frontend <id> react (default) | custom | none
1384
- --instance <slug> target instance for managed deploys (astrale adapter)
1385
1641
  --pm <pm> pnpm | npm | yarn | bun (default: detected, else pnpm)
1386
1642
  --dir <path> target directory (default: ./<slug>)
1387
1643
  --origin <fqdn> domain identity origin (default: <slug>.example.dev)
@@ -1396,15 +1652,6 @@ Non-interactive (also auto-enabled without a TTY, e.g. CI):
1396
1652
  `
1397
1653
  );
1398
1654
  }
1399
- function isValidSlug(v2) {
1400
- return /^[a-z][a-z0-9.-]*$/.test(v2);
1401
- }
1402
- function isValidOrigin(value) {
1403
- if (value.length > 253 || !value.includes(".")) return false;
1404
- return value.split(".").every(
1405
- (label) => label.length > 0 && label.length <= 63 && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/u.test(label)
1406
- );
1407
- }
1408
1655
  function bail() {
1409
1656
  xe("Cancelled.");
1410
1657
  return 1;