@intelligo-dev/cli 1.0.0-beta.1
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 +201 -0
- package/dist/bin.d.ts +14 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +149 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/add.d.ts +48 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +83 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/create.d.ts +33 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +61 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/doctor.d.ts +23 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +129 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/migrate-check.d.ts +44 -0
- package/dist/commands/migrate-check.d.ts.map +1 -0
- package/dist/commands/migrate-check.js +92 -0
- package/dist/commands/migrate-check.js.map +1 -0
- package/dist/commands/upgrade-check.d.ts +40 -0
- package/dist/commands/upgrade-check.d.ts.map +1 -0
- package/dist/commands/upgrade-check.js +91 -0
- package/dist/commands/upgrade-check.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +58 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +65 -0
- package/dist/manifest.js.map +1 -0
- package/dist/migrations-dir.d.ts +13 -0
- package/dist/migrations-dir.d.ts.map +1 -0
- package/dist/migrations-dir.js +25 -0
- package/dist/migrations-dir.js.map +1 -0
- package/dist/migrations.d.ts +41 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +99 -0
- package/dist/migrations.js.map +1 -0
- package/package.json +44 -0
- package/templates/admin-page/admin-page.tsx.tpl +56 -0
- package/templates/app-scaffold/assistant-route.ts.tpl +66 -0
- package/templates/app-scaffold/components.json.tpl +23 -0
- package/templates/app-scaffold/env.example.tpl +13 -0
- package/templates/app-scaffold/globals.css.tpl +329 -0
- package/templates/app-scaffold/i18n-navigation.ts.tpl +10 -0
- package/templates/app-scaffold/i18n-request.ts.tpl +51 -0
- package/templates/app-scaffold/i18n-routing.ts.tpl +13 -0
- package/templates/app-scaffold/intelligo.ts.tpl +84 -0
- package/templates/app-scaffold/layout.tsx.tpl +53 -0
- package/templates/app-scaffold/lib-utils.ts.tpl +6 -0
- package/templates/app-scaffold/messages-en-app.json.tpl +4 -0
- package/templates/app-scaffold/middleware.ts.tpl +11 -0
- package/templates/app-scaffold/next.config.mjs.tpl +19 -0
- package/templates/app-scaffold/package.json.tpl +42 -0
- package/templates/app-scaffold/plans.ts.tpl +43 -0
- package/templates/app-scaffold/postcss.config.mjs.tpl +7 -0
- package/templates/app-scaffold/sonner.tsx.tpl +50 -0
- package/templates/app-scaffold/theme-provider.tsx.tpl +28 -0
- package/templates/app-scaffold/tsconfig.json.tpl +12 -0
- package/templates/billing-page/billing-page.tsx.tpl +72 -0
- package/templates/manifest.json +116 -0
- package/templates/usage-page/usage-page.tsx.tpl +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Intelligo
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* intelligo <command>
|
|
4
|
+
*
|
|
5
|
+
* The shebang targets node because that is what runs the *published*
|
|
6
|
+
* binary from dist/. In this workspace the source is run with
|
|
7
|
+
* `pnpm exec tsx packages/cli/src/bin.ts`.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately tiny: the commands are library functions, and this file
|
|
10
|
+
* only maps argv onto them, opens a database connection when one is
|
|
11
|
+
* needed, and picks an exit code.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=bin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* intelligo <command>
|
|
4
|
+
*
|
|
5
|
+
* The shebang targets node because that is what runs the *published*
|
|
6
|
+
* binary from dist/. In this workspace the source is run with
|
|
7
|
+
* `pnpm exec tsx packages/cli/src/bin.ts`.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately tiny: the commands are library functions, and this file
|
|
10
|
+
* only maps argv onto them, opens a database connection when one is
|
|
11
|
+
* needed, and picks an exit code.
|
|
12
|
+
*/
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { addFeature, formatAddResult, readCatalogue } from "./commands/add.js";
|
|
16
|
+
import { createApp, formatCreateResult } from "./commands/create.js";
|
|
17
|
+
import { exitCodeFor, formatResults, runChecks } from "./commands/doctor.js";
|
|
18
|
+
import { formatMigrateCheck, migrateCheck, migrateCheckExitCode, } from "./commands/migrate-check.js";
|
|
19
|
+
import { formatUpgradeReport, upgradeCheck, upgradeCheckExitCode, } from "./commands/upgrade-check.js";
|
|
20
|
+
import { MIGRATION_LOCATIONS, resolveMigrationsDir } from "./migrations-dir.js";
|
|
21
|
+
/** Templates ship with the CLI package. */
|
|
22
|
+
const TEMPLATES_DIR = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "templates");
|
|
23
|
+
/**
|
|
24
|
+
* Recorded in the manifest so an upgrade knows what wrote a file, and
|
|
25
|
+
* emitted as the dependency range of a scaffolded app. Read from this
|
|
26
|
+
* package's own manifest so a release cannot ship with a stale literal
|
|
27
|
+
* — `../package.json` resolves from src/ and from dist/ alike.
|
|
28
|
+
*/
|
|
29
|
+
const FRAMEWORK_VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
30
|
+
function usage() {
|
|
31
|
+
return [
|
|
32
|
+
"intelligo <command>",
|
|
33
|
+
"",
|
|
34
|
+
" create <dir> Scaffold a new application",
|
|
35
|
+
" doctor Report configuration and migration-chain problems",
|
|
36
|
+
" migrate --check Compare this checkout's migrations to a database",
|
|
37
|
+
" add <feature> Generate consumer-owned source (--force to overwrite)",
|
|
38
|
+
" upgrade --check Show what a template upgrade would change",
|
|
39
|
+
"",
|
|
40
|
+
].join("\n");
|
|
41
|
+
}
|
|
42
|
+
async function runMigrateCheck() {
|
|
43
|
+
const url = process.env.DATABASE_URL;
|
|
44
|
+
if (!url) {
|
|
45
|
+
console.error("DATABASE_URL is required for `migrate --check`.");
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
// Imported lazily so `doctor` — the command you reach for when the
|
|
49
|
+
// app will not start — never needs a database driver to load.
|
|
50
|
+
const { Client } = await import("pg");
|
|
51
|
+
const client = new Client({ connectionString: url });
|
|
52
|
+
await client.connect();
|
|
53
|
+
const migrationsDir = resolveMigrationsDir(process.cwd());
|
|
54
|
+
if (!migrationsDir) {
|
|
55
|
+
console.error(`No migrations directory (looked in ${MIGRATION_LOCATIONS.join(", ")}) — run from the workspace root, with @intelligo-dev/core installed.`);
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const result = await migrateCheck(migrationsDir, async (sql) => (await client.query(sql)).rows);
|
|
60
|
+
console.log(formatMigrateCheck(result));
|
|
61
|
+
return migrateCheckExitCode(result);
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
await client.end();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function main() {
|
|
68
|
+
const [, , command = "help", ...rest] = process.argv;
|
|
69
|
+
switch (command) {
|
|
70
|
+
case "doctor": {
|
|
71
|
+
const results = runChecks();
|
|
72
|
+
console.log(formatResults(results));
|
|
73
|
+
return exitCodeFor(results);
|
|
74
|
+
}
|
|
75
|
+
case "migrate": {
|
|
76
|
+
if (!rest.includes("--check")) {
|
|
77
|
+
console.error("Only `migrate --check` is implemented.");
|
|
78
|
+
console.error("Applying migrations stays with drizzle-kit for now.");
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
return runMigrateCheck();
|
|
82
|
+
}
|
|
83
|
+
case "create": {
|
|
84
|
+
const target = rest.find((a) => !a.startsWith("--"));
|
|
85
|
+
if (!target) {
|
|
86
|
+
console.error("Usage: intelligo create <directory>");
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
const result = createApp({
|
|
90
|
+
target,
|
|
91
|
+
templatesDir: TEMPLATES_DIR,
|
|
92
|
+
frameworkVersion: FRAMEWORK_VERSION,
|
|
93
|
+
// `--link-workspace` is for scaffolding inside the Intelligo
|
|
94
|
+
// monorepo, where the packages are workspace members. The
|
|
95
|
+
// default is a version range, because that is what works
|
|
96
|
+
// everywhere else.
|
|
97
|
+
linkWorkspace: rest.includes("--link-workspace"),
|
|
98
|
+
});
|
|
99
|
+
console.log(formatCreateResult(target, result));
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
case "add": {
|
|
103
|
+
const feature = rest.find((a) => !a.startsWith("--"));
|
|
104
|
+
if (!feature) {
|
|
105
|
+
const catalogue = readCatalogue(TEMPLATES_DIR);
|
|
106
|
+
console.error("Usage: intelligo add <feature>\n");
|
|
107
|
+
for (const [name, spec] of Object.entries(catalogue)) {
|
|
108
|
+
console.error(` ${name.padEnd(16)} ${spec.description}`);
|
|
109
|
+
}
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
const result = addFeature(feature, {
|
|
113
|
+
appRoot: process.cwd(),
|
|
114
|
+
templatesDir: TEMPLATES_DIR,
|
|
115
|
+
frameworkVersion: FRAMEWORK_VERSION,
|
|
116
|
+
force: rest.includes("--force"),
|
|
117
|
+
});
|
|
118
|
+
console.log(formatAddResult(result));
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
case "upgrade": {
|
|
122
|
+
if (!rest.includes("--check")) {
|
|
123
|
+
console.error("Only `upgrade --check` is implemented.");
|
|
124
|
+
console.error("Applying an upgrade means re-running `intelligo add` for the " +
|
|
125
|
+
"features it reports as outdated — deliberately your call, " +
|
|
126
|
+
"since the files are yours.");
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
const report = upgradeCheck({
|
|
130
|
+
appRoot: process.cwd(),
|
|
131
|
+
templatesDir: TEMPLATES_DIR,
|
|
132
|
+
});
|
|
133
|
+
console.log(formatUpgradeReport(report));
|
|
134
|
+
return upgradeCheckExitCode(report);
|
|
135
|
+
}
|
|
136
|
+
case "help":
|
|
137
|
+
console.log(usage());
|
|
138
|
+
return 0;
|
|
139
|
+
default:
|
|
140
|
+
console.error(`Unknown command: ${command}\n`);
|
|
141
|
+
console.error(usage());
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
main().then((code) => process.exit(code), (error) => {
|
|
146
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
147
|
+
process.exit(1);
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,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;IACb,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,IAAI,CACT,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `intelligo add <feature>` — generate consumer-owned source.
|
|
3
|
+
*
|
|
4
|
+
* "Owned" is the operative word (ADR-0002): the files land in the
|
|
5
|
+
* consumer's repository and Intelligo stops deciding what is in them.
|
|
6
|
+
* The manifest records what was written and its hash so a later
|
|
7
|
+
* upgrade can tell an untouched file from one the consumer has made
|
|
8
|
+
* their own, and refuse to overwrite the latter.
|
|
9
|
+
*/
|
|
10
|
+
export type TemplateFile = {
|
|
11
|
+
template: string;
|
|
12
|
+
target: string;
|
|
13
|
+
};
|
|
14
|
+
export type TemplateFeature = {
|
|
15
|
+
templateVersion: string;
|
|
16
|
+
description: string;
|
|
17
|
+
/** Set when a registry item supersedes this template feature. */
|
|
18
|
+
deprecated?: string;
|
|
19
|
+
files: TemplateFile[];
|
|
20
|
+
};
|
|
21
|
+
export type TemplateCatalogue = Record<string, TemplateFeature>;
|
|
22
|
+
export declare function readCatalogue(templatesDir: string): TemplateCatalogue;
|
|
23
|
+
export type AddResult = {
|
|
24
|
+
feature: string;
|
|
25
|
+
/** The catalogue's deprecation notice, when the feature has one. */
|
|
26
|
+
deprecated?: string;
|
|
27
|
+
written: string[];
|
|
28
|
+
/** Present and modified by the consumer — left untouched. */
|
|
29
|
+
skippedCustomized: string[];
|
|
30
|
+
/** Present but not ours (no manifest record) — left untouched. */
|
|
31
|
+
skippedUnknown: string[];
|
|
32
|
+
};
|
|
33
|
+
export type AddOptions = {
|
|
34
|
+
appRoot: string;
|
|
35
|
+
templatesDir: string;
|
|
36
|
+
frameworkVersion: string;
|
|
37
|
+
/** Re-write files the consumer has customized. Off by default. */
|
|
38
|
+
force?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Placeholder substitutions applied to template contents, e.g.
|
|
41
|
+
* `{ __APP_NAME__: "acme" }`. Applied before hashing, so the
|
|
42
|
+
* recorded hash describes what actually landed on disk.
|
|
43
|
+
*/
|
|
44
|
+
variables?: Record<string, string>;
|
|
45
|
+
};
|
|
46
|
+
export declare function addFeature(feature: string, options: AddOptions): AddResult;
|
|
47
|
+
export declare function formatAddResult(r: AddResult): string;
|
|
48
|
+
//# sourceMappingURL=add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEhE,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,iBAAiB,CAIrE;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,6DAA6D;IAC7D,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,kEAAkE;IAClE,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAaF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,CAiE1E;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAWpD"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `intelligo add <feature>` — generate consumer-owned source.
|
|
3
|
+
*
|
|
4
|
+
* "Owned" is the operative word (ADR-0002): the files land in the
|
|
5
|
+
* consumer's repository and Intelligo stops deciding what is in them.
|
|
6
|
+
* The manifest records what was written and its hash so a later
|
|
7
|
+
* upgrade can tell an untouched file from one the consumer has made
|
|
8
|
+
* their own, and refuse to overwrite the latter.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { emptyManifest, hashContents, readManifest, recordFeature, writeManifest, } from "../manifest.js";
|
|
13
|
+
export function readCatalogue(templatesDir) {
|
|
14
|
+
return JSON.parse(readFileSync(path.join(templatesDir, "manifest.json"), "utf8"));
|
|
15
|
+
}
|
|
16
|
+
function substitute(contents, variables) {
|
|
17
|
+
if (!variables)
|
|
18
|
+
return contents;
|
|
19
|
+
return Object.entries(variables).reduce((out, [key, value]) => out.split(key).join(value), contents);
|
|
20
|
+
}
|
|
21
|
+
export function addFeature(feature, options) {
|
|
22
|
+
const catalogue = readCatalogue(options.templatesDir);
|
|
23
|
+
const spec = catalogue[feature];
|
|
24
|
+
if (!spec) {
|
|
25
|
+
throw new Error(`Unknown feature "${feature}". Available: ${Object.keys(catalogue).join(", ")}`);
|
|
26
|
+
}
|
|
27
|
+
const manifest = readManifest(options.appRoot) ?? emptyManifest(options.frameworkVersion);
|
|
28
|
+
const previous = manifest.features[feature];
|
|
29
|
+
const previousByPath = new Map((previous?.files ?? []).map((f) => [f.path, f]));
|
|
30
|
+
const result = {
|
|
31
|
+
feature,
|
|
32
|
+
written: [],
|
|
33
|
+
skippedCustomized: [],
|
|
34
|
+
skippedUnknown: [],
|
|
35
|
+
};
|
|
36
|
+
if (spec.deprecated)
|
|
37
|
+
result.deprecated = spec.deprecated;
|
|
38
|
+
const recorded = [];
|
|
39
|
+
for (const file of spec.files) {
|
|
40
|
+
const source = path.join(options.templatesDir, file.template);
|
|
41
|
+
const target = path.join(options.appRoot, file.target);
|
|
42
|
+
const contents = substitute(readFileSync(source, "utf8"), options.variables);
|
|
43
|
+
if (existsSync(target) && !options.force) {
|
|
44
|
+
const current = hashContents(readFileSync(target, "utf8"));
|
|
45
|
+
const known = previousByPath.get(file.target);
|
|
46
|
+
if (!known) {
|
|
47
|
+
// Not ours: a file we never generated already occupies the
|
|
48
|
+
// path. Overwriting it would destroy work we cannot attribute.
|
|
49
|
+
result.skippedUnknown.push(file.target);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (current !== known.hash) {
|
|
53
|
+
result.skippedCustomized.push(file.target);
|
|
54
|
+
// Keep the ORIGINAL hash: it is the baseline that says "this is
|
|
55
|
+
// customized", and replacing it with the current hash would
|
|
56
|
+
// silently re-adopt the consumer's file as ours.
|
|
57
|
+
recorded.push(known);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
mkdirSync(path.dirname(target), { recursive: true });
|
|
62
|
+
writeFileSync(target, contents);
|
|
63
|
+
recorded.push({ path: file.target, hash: hashContents(contents) });
|
|
64
|
+
result.written.push(file.target);
|
|
65
|
+
}
|
|
66
|
+
writeManifest(options.appRoot, recordFeature(manifest, feature, spec.templateVersion, recorded));
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
export function formatAddResult(r) {
|
|
70
|
+
const lines = [`${r.feature}:`];
|
|
71
|
+
if (r.deprecated)
|
|
72
|
+
lines.push(` ⚠ deprecated: ${r.deprecated}`);
|
|
73
|
+
for (const f of r.written)
|
|
74
|
+
lines.push(` + ${f}`);
|
|
75
|
+
for (const f of r.skippedCustomized)
|
|
76
|
+
lines.push(` = ${f} (yours — left alone; use --force to overwrite)`);
|
|
77
|
+
for (const f of r.skippedUnknown)
|
|
78
|
+
lines.push(` ! ${f} (already exists and was not generated by Intelligo)`);
|
|
79
|
+
if (r.written.length === 0 && r.skippedCustomized.length === 0)
|
|
80
|
+
lines.push(" nothing to do");
|
|
81
|
+
return lines.join("\n");
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,GAEd,MAAM,gBAAgB,CAAC;AAYxB,MAAM,UAAU,aAAa,CAAC,YAAoB;IAChD,OAAO,IAAI,CAAC,KAAK,CACf,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAC1C,CAAC;AACzB,CAAC;AA2BD,SAAS,UAAU,CACjB,QAAgB,EAChB,SAA6C;IAE7C,IAAI,CAAC,SAAS;QAAE,OAAO,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boarding, not the product
|
|
5
|
+
* boundary: what it writes is the consumer's from the moment it lands,
|
|
6
|
+
* and the enduring relationship is the versioned packages, not this
|
|
7
|
+
* scaffold. So it generates through the same manifest machinery as
|
|
8
|
+
* `add`, which means the very first upgrade already knows which files
|
|
9
|
+
* you have since edited.
|
|
10
|
+
*/
|
|
11
|
+
import { type AddResult } from "./add.js";
|
|
12
|
+
export type CreateOptions = {
|
|
13
|
+
/** Directory to create the app in; created if absent. */
|
|
14
|
+
target: string;
|
|
15
|
+
templatesDir: string;
|
|
16
|
+
frameworkVersion: string;
|
|
17
|
+
/**
|
|
18
|
+
* Emit `workspace:*` for the @intelligo-dev/* dependencies instead of a
|
|
19
|
+
* version range. Only meaningful when scaffolding inside this
|
|
20
|
+
* monorepo — outside it, pnpm fails the install with "workspace
|
|
21
|
+
* protocol used outside a workspace", which is the first thing a new
|
|
22
|
+
* user would have seen.
|
|
23
|
+
*/
|
|
24
|
+
linkWorkspace?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** A package name and product slug derived from the directory name. */
|
|
27
|
+
export declare function deriveNames(target: string): {
|
|
28
|
+
appName: string;
|
|
29
|
+
appSlug: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function createApp(options: CreateOptions): AddResult;
|
|
32
|
+
export declare function formatCreateResult(target: string, r: AddResult): string;
|
|
33
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAEvE,MAAM,MAAM,aAAa,GAAG;IAC1B,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAUA;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CA0B3D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAYvE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `intelligo create <name>` — a new application on the framework.
|
|
3
|
+
*
|
|
4
|
+
* ADR-0001 is explicit that this is onboarding, not the product
|
|
5
|
+
* boundary: what it writes is the consumer's from the moment it lands,
|
|
6
|
+
* and the enduring relationship is the versioned packages, not this
|
|
7
|
+
* scaffold. So it generates through the same manifest machinery as
|
|
8
|
+
* `add`, which means the very first upgrade already knows which files
|
|
9
|
+
* you have since edited.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, mkdirSync, readdirSync } from "node:fs";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { addFeature, formatAddResult } from "./add.js";
|
|
14
|
+
/** A package name and product slug derived from the directory name. */
|
|
15
|
+
export function deriveNames(target) {
|
|
16
|
+
const base = path.basename(path.resolve(target));
|
|
17
|
+
const slug = base
|
|
18
|
+
.toLowerCase()
|
|
19
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
20
|
+
.replace(/^-+|-+$/g, "");
|
|
21
|
+
if (!slug) {
|
|
22
|
+
throw new Error(`Cannot derive a project name from "${target}".`);
|
|
23
|
+
}
|
|
24
|
+
return { appName: slug, appSlug: slug };
|
|
25
|
+
}
|
|
26
|
+
export function createApp(options) {
|
|
27
|
+
const target = path.resolve(options.target);
|
|
28
|
+
if (existsSync(target) && readdirSync(target).length > 0) {
|
|
29
|
+
// Scaffolding into an occupied directory is how people lose work.
|
|
30
|
+
throw new Error(`${target} is not empty. Create the app in a new directory, or use ` +
|
|
31
|
+
`\`intelligo add app-scaffold\` inside an existing one.`);
|
|
32
|
+
}
|
|
33
|
+
mkdirSync(target, { recursive: true });
|
|
34
|
+
const { appName, appSlug } = deriveNames(target);
|
|
35
|
+
return addFeature("app-scaffold", {
|
|
36
|
+
appRoot: target,
|
|
37
|
+
templatesDir: options.templatesDir,
|
|
38
|
+
frameworkVersion: options.frameworkVersion,
|
|
39
|
+
variables: {
|
|
40
|
+
__APP_NAME__: appName,
|
|
41
|
+
__APP_SLUG__: appSlug,
|
|
42
|
+
__INTELLIGO_DEP__: options.linkWorkspace
|
|
43
|
+
? "workspace:*"
|
|
44
|
+
: `^${options.frameworkVersion}`,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export function formatCreateResult(target, r) {
|
|
49
|
+
return [
|
|
50
|
+
formatAddResult(r),
|
|
51
|
+
"",
|
|
52
|
+
"Next:",
|
|
53
|
+
` cd ${path.relative(process.cwd(), path.resolve(target)) || "."}`,
|
|
54
|
+
" cp .env.example .env.local # then fill it in",
|
|
55
|
+
" pnpm install",
|
|
56
|
+
" pnpm dev",
|
|
57
|
+
"",
|
|
58
|
+
"`intelligo doctor` will tell you what is still missing.",
|
|
59
|
+
].join("\n");
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAkB,MAAM,UAAU,CAAC;AAiBvE,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,MAAc;IAIxC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAA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EAAE,CAAY;IAC7D,OAAO;QACL,eAAe,CAAC,CAAC,CAAC;QAClB,EAAE;QACF,OAAO;QACP,QAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,GAAG,EAAE;QACnE,kDAAkD;QAClD,gBAAgB;QAChB,YAAY;QACZ,EAAE;QACF,yDAAyD;KAC1D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `intelligo doctor` — report the problems that are invisible until
|
|
3
|
+
* they are an incident.
|
|
4
|
+
*
|
|
5
|
+
* The checks here were each chosen because something in this codebase
|
|
6
|
+
* actually went wrong that way, not because they sounded thorough.
|
|
7
|
+
*/
|
|
8
|
+
export type CheckResult = {
|
|
9
|
+
name: string;
|
|
10
|
+
status: "ok" | "warn" | "error";
|
|
11
|
+
detail: string;
|
|
12
|
+
};
|
|
13
|
+
export type DoctorOptions = {
|
|
14
|
+
/** Workspace root; defaults to the current working directory. */
|
|
15
|
+
root?: string;
|
|
16
|
+
/** Environment to validate; defaults to process.env. */
|
|
17
|
+
env?: NodeJS.ProcessEnv;
|
|
18
|
+
};
|
|
19
|
+
export declare function runChecks(options?: DoctorOptions): CheckResult[];
|
|
20
|
+
export declare function formatResults(results: CheckResult[]): string;
|
|
21
|
+
/** Process exit code: non-zero when any check errored. */
|
|
22
|
+
export declare function exitCodeFor(results: CheckResult[]): number;
|
|
23
|
+
//# sourceMappingURL=doctor.d.ts.map
|