create-astrale-domain 0.2.1 → 0.2.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.
- package/LICENSE +202 -0
- package/dist/index.js +93 -128
- package/package.json +5 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Astrale
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/dist/index.js
CHANGED
|
@@ -780,7 +780,7 @@ import { existsSync as existsSync2 } from "node:fs";
|
|
|
780
780
|
import { delimiter, join as join2, relative as relative2, resolve as resolve2 } from "node:path";
|
|
781
781
|
|
|
782
782
|
// src/scaffold.ts
|
|
783
|
-
import { existsSync } from "node:fs";
|
|
783
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
784
784
|
import { cp, readFile, rm, writeFile } from "node:fs/promises";
|
|
785
785
|
import { createRequire } from "node:module";
|
|
786
786
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
@@ -804,7 +804,43 @@ var ADAPTER_PACKAGES = {
|
|
|
804
804
|
astrale: "@astrale-os/adapter-astrale",
|
|
805
805
|
cloudflare: "@astrale-os/adapter-cloudflare"
|
|
806
806
|
};
|
|
807
|
-
|
|
807
|
+
function packageJson(pkgName) {
|
|
808
|
+
const rel = LINK_TARGETS[pkgName];
|
|
809
|
+
if (rel) {
|
|
810
|
+
const local = join(WORKSPACE_ROOT, rel, "package.json");
|
|
811
|
+
if (existsSync(local)) return JSON.parse(readFileSync(local, "utf-8"));
|
|
812
|
+
}
|
|
813
|
+
const direct = tryPackageJson(require2, pkgName);
|
|
814
|
+
if (direct) return direct;
|
|
815
|
+
for (const owner of /* @__PURE__ */ new Set([BODY_PACKAGE, ...Object.values(ADAPTER_PACKAGES)])) {
|
|
816
|
+
const ownerPkgPath = tryResolve(`${owner}/package.json`);
|
|
817
|
+
if (!ownerPkgPath) continue;
|
|
818
|
+
const ownerRequire = createRequire(ownerPkgPath);
|
|
819
|
+
const nested = tryPackageJson(ownerRequire, pkgName);
|
|
820
|
+
if (nested) return nested;
|
|
821
|
+
}
|
|
822
|
+
throw new Error(`Could not read ${pkgName} package.json.`);
|
|
823
|
+
}
|
|
824
|
+
function tryResolve(id) {
|
|
825
|
+
try {
|
|
826
|
+
return require2.resolve(id);
|
|
827
|
+
} catch {
|
|
828
|
+
return void 0;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
function tryPackageJson(req, pkgName) {
|
|
832
|
+
try {
|
|
833
|
+
return req(`${pkgName}/package.json`);
|
|
834
|
+
} catch {
|
|
835
|
+
return void 0;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function publishedDepVersion(pkgName) {
|
|
839
|
+
const pkg = packageJson(pkgName);
|
|
840
|
+
const version = pkg.version;
|
|
841
|
+
if (!version) throw new Error(`Could not read ${pkgName} package version.`);
|
|
842
|
+
return version;
|
|
843
|
+
}
|
|
808
844
|
function templateDir(pkg) {
|
|
809
845
|
return join(dirname(require2.resolve(`${pkg}/package.json`)), "template");
|
|
810
846
|
}
|
|
@@ -819,19 +855,19 @@ async function scaffold(opts) {
|
|
|
819
855
|
}
|
|
820
856
|
await cp(src, opts.dir, {
|
|
821
857
|
recursive: true,
|
|
822
|
-
filter: (s) => !/\/(node_modules|\.astrale|dist-client|\.wrangler|pnpm-lock\.yaml)(\/|$)/.test(
|
|
858
|
+
filter: (s) => !/\/(node_modules|\.astrale|\.dist|\.domain-studio|dist-client|\.wrangler|pnpm-lock\.yaml|\.DS_Store)(\/|$)/.test(
|
|
823
859
|
`/${relative(src, s)}`
|
|
824
860
|
)
|
|
825
861
|
});
|
|
826
862
|
await materializeAdapter(opts);
|
|
827
863
|
await stampOrigin(opts.dir, opts.origin);
|
|
828
864
|
await rewritePackageJson(opts.dir, opts.name, opts.link);
|
|
829
|
-
|
|
865
|
+
await rewriteWorkspaceMember(join(opts.dir, "client", "package.json"), opts.link);
|
|
866
|
+
if (!opts.link) await writeReleaseAgePolicy(opts.dir);
|
|
830
867
|
await writeFile(
|
|
831
868
|
join(opts.dir, ".env.dev"),
|
|
832
869
|
"# Dev secrets \u2014 the ENTIRE file is injected into the local runtime by `pnpm dev`.\n# Gitignored. See .env.example.\n"
|
|
833
870
|
);
|
|
834
|
-
if (opts.template === "blank") await blankOut(opts.dir, opts.origin);
|
|
835
871
|
}
|
|
836
872
|
function assertSafeToDelete(dir) {
|
|
837
873
|
const target = resolve(dir);
|
|
@@ -860,37 +896,24 @@ async function setAdapterDep(dir, from, to) {
|
|
|
860
896
|
const pkg = JSON.parse(await readFile(path, "utf-8"));
|
|
861
897
|
if (!pkg.dependencies || !(from in pkg.dependencies)) return;
|
|
862
898
|
delete pkg.dependencies[from];
|
|
863
|
-
pkg.dependencies[to] =
|
|
899
|
+
pkg.dependencies[to] = publishedDepVersion(to);
|
|
864
900
|
pkg.dependencies = Object.fromEntries(
|
|
865
901
|
Object.entries(pkg.dependencies).sort(([a], [b3]) => a.localeCompare(b3))
|
|
866
902
|
);
|
|
867
903
|
await writeFile(path, JSON.stringify(pkg, null, 2) + "\n");
|
|
868
904
|
}
|
|
869
|
-
async function
|
|
905
|
+
async function rewriteWorkspaceMember(pkgPath, link) {
|
|
870
906
|
if (!existsSync(pkgPath)) return;
|
|
871
907
|
const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
872
|
-
|
|
873
|
-
for (const group of [pkg.dependencies, pkg.devDependencies]) {
|
|
874
|
-
if (!group) continue;
|
|
875
|
-
for (const [dep, rel] of Object.entries(LINK_TARGETS)) {
|
|
876
|
-
if (dep in group) {
|
|
877
|
-
group[dep] = `link:${join(WORKSPACE_ROOT, rel)}`;
|
|
878
|
-
changed = true;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
908
|
+
const changed = rewriteAstraleDeps(pkg, link);
|
|
882
909
|
if (changed) await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
883
910
|
}
|
|
884
911
|
async function rewritePackageJson(dir, name, link) {
|
|
885
912
|
const path = join(dir, "package.json");
|
|
886
913
|
const pkg = JSON.parse(await readFile(path, "utf-8"));
|
|
887
914
|
pkg.name = name;
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
if (dep in pkg.dependencies) {
|
|
891
|
-
pkg.dependencies[dep] = `link:${join(WORKSPACE_ROOT, rel)}`;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
915
|
+
rewriteAstraleDeps(pkg, link);
|
|
916
|
+
if (link) {
|
|
894
917
|
pkg.pnpm = {
|
|
895
918
|
...pkg.pnpm,
|
|
896
919
|
overrides: {
|
|
@@ -901,89 +924,55 @@ async function rewritePackageJson(dir, name, link) {
|
|
|
901
924
|
}
|
|
902
925
|
await writeFile(path, JSON.stringify(pkg, null, 2) + "\n");
|
|
903
926
|
}
|
|
927
|
+
function rewriteAstraleDeps(pkg, link) {
|
|
928
|
+
let changed = false;
|
|
929
|
+
for (const group of [pkg.dependencies, pkg.devDependencies]) {
|
|
930
|
+
if (!group) continue;
|
|
931
|
+
for (const dep of Object.keys(group)) {
|
|
932
|
+
if (!dep.startsWith("@astrale-os/")) continue;
|
|
933
|
+
const next = link && LINK_TARGETS[dep] ? `link:${join(WORKSPACE_ROOT, LINK_TARGETS[dep])}` : publishedDepVersion(dep);
|
|
934
|
+
if (group[dep] !== next) {
|
|
935
|
+
group[dep] = next;
|
|
936
|
+
changed = true;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return changed;
|
|
941
|
+
}
|
|
942
|
+
async function writeReleaseAgePolicy(dir) {
|
|
943
|
+
const workspace = join(dir, "pnpm-workspace.yaml");
|
|
944
|
+
if (!existsSync(workspace)) return;
|
|
945
|
+
const names = /* @__PURE__ */ new Set();
|
|
946
|
+
for (const pkgPath of [join(dir, "package.json"), join(dir, "client", "package.json")]) {
|
|
947
|
+
if (!existsSync(pkgPath)) continue;
|
|
948
|
+
const pkg = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
949
|
+
for (const group of [pkg.dependencies, pkg.devDependencies]) {
|
|
950
|
+
for (const [name, spec] of Object.entries(group ?? {})) {
|
|
951
|
+
if (name.startsWith("@astrale-os/") && !spec.startsWith("link:")) names.add(name);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
if (names.size === 0) return;
|
|
956
|
+
const start = "# create-astrale-domain: exact first-party deps";
|
|
957
|
+
const end = "# /create-astrale-domain";
|
|
958
|
+
const block = `
|
|
959
|
+
${start}
|
|
960
|
+
minimumReleaseAgeExclude:
|
|
961
|
+
` + [...names].sort().map((name) => ` - '${name}'`).join("\n") + `
|
|
962
|
+
${end}
|
|
963
|
+
`;
|
|
964
|
+
const text = await readFile(workspace, "utf-8");
|
|
965
|
+
const pattern = new RegExp(`\\n?${escapeRegExp(start)}[\\s\\S]*?${escapeRegExp(end)}\\n?`);
|
|
966
|
+
await writeFile(workspace, text.replace(pattern, "\n").trimEnd() + block);
|
|
967
|
+
}
|
|
968
|
+
function escapeRegExp(value) {
|
|
969
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
970
|
+
}
|
|
904
971
|
function sdkZodVersion() {
|
|
905
972
|
const sdkRequire = createRequire(join(WORKSPACE_ROOT, "sdk", "package.json"));
|
|
906
973
|
const pkg = sdkRequire("zod/package.json");
|
|
907
974
|
return pkg.version;
|
|
908
975
|
}
|
|
909
|
-
async function blankOut(dir, origin) {
|
|
910
|
-
await writeFile(
|
|
911
|
-
join(dir, "schema", "monitor.ts"),
|
|
912
|
-
`// Author your classes/interfaces here, then register them in schema/index.ts.
|
|
913
|
-
export {}
|
|
914
|
-
`
|
|
915
|
-
);
|
|
916
|
-
await writeFile(
|
|
917
|
-
join(dir, "schema", "index.ts"),
|
|
918
|
-
`import { defineSchema, KernelSchema } from '@astrale-os/kernel-core'
|
|
919
|
-
|
|
920
|
-
export const schema = defineSchema('${origin}', {
|
|
921
|
-
interfaces: {},
|
|
922
|
-
classes: {},
|
|
923
|
-
imports: [KernelSchema],
|
|
924
|
-
})
|
|
925
|
-
`
|
|
926
|
-
);
|
|
927
|
-
await writeFile(
|
|
928
|
-
join(dir, "env.ts"),
|
|
929
|
-
`/**
|
|
930
|
-
* Worker runtime env. The adapter injects \`WORKER_URL\` and the bindings; your
|
|
931
|
-
* handlers receive this (mapped by deps.ts) as \`ctx.deps\`. Secrets from
|
|
932
|
-
* \`.env.<env>\` arrive as extra string fields here. Add typed fields as you
|
|
933
|
-
* reference new secrets/vars.
|
|
934
|
-
*/
|
|
935
|
-
export interface Env {
|
|
936
|
-
WORKER_URL?: string
|
|
937
|
-
ASSETS?: { fetch(request: Request): Promise<Response> }
|
|
938
|
-
SELF?: { fetch(request: Request): Promise<Response> }
|
|
939
|
-
VIEW_DEV_URL?: string
|
|
940
|
-
[key: string]: unknown
|
|
941
|
-
}
|
|
942
|
-
`
|
|
943
|
-
);
|
|
944
|
-
await writeFile(
|
|
945
|
-
join(dir, "deps.ts"),
|
|
946
|
-
`/**
|
|
947
|
-
* env \u2192 handler dependency container (the seam \`defineDomain({ deps })\` mounts).
|
|
948
|
-
* Passthrough by default; transform here the moment a handler should depend on a
|
|
949
|
-
* PORT (built from \`integrations/\`) instead of raw env.
|
|
950
|
-
*/
|
|
951
|
-
import type { Env } from './env'
|
|
952
|
-
|
|
953
|
-
export interface Deps extends Env {}
|
|
954
|
-
|
|
955
|
-
export function deps(env: Env): Deps {
|
|
956
|
-
return env
|
|
957
|
-
}
|
|
958
|
-
`
|
|
959
|
-
);
|
|
960
|
-
await writeFile(
|
|
961
|
-
join(dir, "runtime", "index.ts"),
|
|
962
|
-
`import type { SchemaMethodsImpl } from '@astrale-os/sdk'
|
|
963
|
-
|
|
964
|
-
import type { Deps } from '../deps'
|
|
965
|
-
import { schema } from '../schema'
|
|
966
|
-
|
|
967
|
-
export const methods: SchemaMethodsImpl<typeof schema, Deps> = { class: {} }
|
|
968
|
-
`
|
|
969
|
-
);
|
|
970
|
-
await writeFile(join(dir, "functions", "index.ts"), `export const functions = {}
|
|
971
|
-
`);
|
|
972
|
-
await writeFile(join(dir, "views", "index.ts"), `export const views = {}
|
|
973
|
-
`);
|
|
974
|
-
await rm(join(dir, "core"), { recursive: true, force: true });
|
|
975
|
-
await rm(join(dir, "integrations"), { recursive: true, force: true });
|
|
976
|
-
await rm(join(dir, "views", "welcome.ts"), { force: true });
|
|
977
|
-
await rm(join(dir, "views", "status-page.ts"), { force: true });
|
|
978
|
-
await rm(join(dir, "runtime", "monitor"), { recursive: true, force: true });
|
|
979
|
-
await rm(join(dir, "runtime", "status-page"), { recursive: true, force: true });
|
|
980
|
-
await rm(join(dir, "runtime", "shared.ts"), { force: true });
|
|
981
|
-
await replaceInFile(
|
|
982
|
-
join(dir, "domain.ts"),
|
|
983
|
-
/\n\s*postInstall: `\/:\$\{schema\.domain\}:class\.Monitor:seed`,/,
|
|
984
|
-
""
|
|
985
|
-
);
|
|
986
|
-
}
|
|
987
976
|
async function replaceInFile(path, from, to) {
|
|
988
977
|
if (!existsSync(path)) return;
|
|
989
978
|
const text = await readFile(path, "utf-8");
|
|
@@ -1079,26 +1068,6 @@ async function main() {
|
|
|
1079
1068
|
if (pD(answer)) return bail();
|
|
1080
1069
|
if (answer) instance = answer;
|
|
1081
1070
|
}
|
|
1082
|
-
let template = flags.template;
|
|
1083
|
-
if (!template) {
|
|
1084
|
-
if (headless) template = "template";
|
|
1085
|
-
else {
|
|
1086
|
-
const answer = await ve({
|
|
1087
|
-
message: "Start from?",
|
|
1088
|
-
initialValue: "template",
|
|
1089
|
-
options: [
|
|
1090
|
-
{
|
|
1091
|
-
value: "template",
|
|
1092
|
-
label: "Template",
|
|
1093
|
-
hint: 'a working "Monitor" class + a view + a seed'
|
|
1094
|
-
},
|
|
1095
|
-
{ value: "blank", label: "Blank" }
|
|
1096
|
-
]
|
|
1097
|
-
});
|
|
1098
|
-
if (pD(answer)) return bail();
|
|
1099
|
-
template = answer;
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
1071
|
let pm = flags.pm;
|
|
1103
1072
|
if (!pm) {
|
|
1104
1073
|
const detected = detectPm();
|
|
@@ -1136,7 +1105,6 @@ async function main() {
|
|
|
1136
1105
|
name: slug,
|
|
1137
1106
|
origin,
|
|
1138
1107
|
adapter,
|
|
1139
|
-
template,
|
|
1140
1108
|
instance,
|
|
1141
1109
|
link
|
|
1142
1110
|
});
|
|
@@ -1167,8 +1135,7 @@ async function main() {
|
|
|
1167
1135
|
);
|
|
1168
1136
|
}
|
|
1169
1137
|
M2.info(
|
|
1170
|
-
|
|
1171
|
-
Agent rooted at a parent workspace? Register the skills there: npx skills add ${cdTarget === dir ? dir : `./${cdTarget}`}/.agents/skills -y`
|
|
1138
|
+
"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`"
|
|
1172
1139
|
);
|
|
1173
1140
|
Se(`\u2713 ${slug} ready`);
|
|
1174
1141
|
return 0;
|
|
@@ -1183,8 +1150,8 @@ function installStep(pm) {
|
|
|
1183
1150
|
if (astraleOnPath()) return "astrale domain install <url> --direct # mount it on an instance";
|
|
1184
1151
|
return [
|
|
1185
1152
|
"# astrale CLI not found on PATH \u2014 run it on demand (no install):",
|
|
1186
|
-
`${DLX[pm]} @astrale-os/
|
|
1187
|
-
"# or install it globally: npm i -g @astrale-os/
|
|
1153
|
+
`${DLX[pm]} @astrale-os/cli domain install <url> --direct`,
|
|
1154
|
+
"# or install it globally: npm i -g @astrale-os/cli"
|
|
1188
1155
|
].join("\n");
|
|
1189
1156
|
}
|
|
1190
1157
|
function astraleOnPath() {
|
|
@@ -1207,7 +1174,6 @@ function parseFlags(argv) {
|
|
|
1207
1174
|
else if (a === "--link") flags.link = true;
|
|
1208
1175
|
else if (a === "--no-link") flags.link = false;
|
|
1209
1176
|
else if (a === "--adapter") flags.adapter = argv[++i];
|
|
1210
|
-
else if (a === "--template") flags.template = argv[++i];
|
|
1211
1177
|
else if (a === "--pm") flags.pm = argv[++i];
|
|
1212
1178
|
else if (a === "--dir") flags.dir = argv[++i];
|
|
1213
1179
|
else if (a === "--origin") flags.origin = argv[++i];
|
|
@@ -1231,7 +1197,6 @@ Arguments:
|
|
|
1231
1197
|
Options:
|
|
1232
1198
|
--adapter <id> deployment adapter \u2014 astrale (managed, default) | cloudflare
|
|
1233
1199
|
--instance <slug> target instance for managed deploys (astrale adapter)
|
|
1234
|
-
--template <kind> template | blank (default: template)
|
|
1235
1200
|
--pm <pm> pnpm | npm | yarn | bun (default: detected, else pnpm)
|
|
1236
1201
|
--dir <path> target directory (default: ./<slug>)
|
|
1237
1202
|
--origin <fqdn> domain identity origin (default: <slug>.example.dev)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astrale-domain",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Scaffold a standalone Astrale domain — npm create astrale-domain",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"domain",
|
|
9
9
|
"scaffold"
|
|
10
10
|
],
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
12
|
"author": "Astrale",
|
|
13
13
|
"bin": {
|
|
14
14
|
"create-astrale-domain": "./dist/index.js"
|
|
@@ -19,15 +19,15 @@
|
|
|
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.3.0",
|
|
23
|
+
"@astrale-os/adapter-cloudflare": "^0.3.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@astrale-os/ox": ">=0.1.0 <1.0.0",
|
|
27
27
|
"@types/node": "^22.0.0",
|
|
28
28
|
"@typescript/native-preview": "latest",
|
|
29
29
|
"esbuild": "^0.25.4",
|
|
30
|
-
"oxfmt": "
|
|
30
|
+
"oxfmt": "0.52.0",
|
|
31
31
|
"oxlint": "latest",
|
|
32
32
|
"typescript": "~6.0.1-rc",
|
|
33
33
|
"vitest": "^3.0.0"
|