@allstak/wizard 0.1.3 → 0.1.5
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/CHANGELOG.md +53 -1
- package/LICENSE +191 -0
- package/README.md +299 -47
- package/dist/api/http.d.ts +2 -0
- package/dist/api/http.d.ts.map +1 -1
- package/dist/api/http.js +6 -0
- package/dist/api/http.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +3 -3
- package/dist/api/types.js +3 -3
- package/dist/certification/fixtures.d.ts +4 -0
- package/dist/certification/fixtures.d.ts.map +1 -0
- package/dist/certification/fixtures.js +109 -0
- package/dist/certification/fixtures.js.map +1 -0
- package/dist/certification/gates.d.ts +10 -0
- package/dist/certification/gates.d.ts.map +1 -0
- package/dist/certification/gates.js +20 -0
- package/dist/certification/gates.js.map +1 -0
- package/dist/certification/index.d.ts +6 -0
- package/dist/certification/index.d.ts.map +1 -0
- package/dist/certification/index.js +5 -0
- package/dist/certification/index.js.map +1 -0
- package/dist/certification/live-backend.d.ts +50 -0
- package/dist/certification/live-backend.d.ts.map +1 -0
- package/dist/certification/live-backend.js +422 -0
- package/dist/certification/live-backend.js.map +1 -0
- package/dist/certification/packages.d.ts +3 -0
- package/dist/certification/packages.d.ts.map +1 -0
- package/dist/certification/packages.js +49 -0
- package/dist/certification/packages.js.map +1 -0
- package/dist/certification/process.d.ts +8 -0
- package/dist/certification/process.d.ts.map +1 -0
- package/dist/certification/process.js +77 -0
- package/dist/certification/process.js.map +1 -0
- package/dist/certification/report.d.ts +3 -0
- package/dist/certification/report.d.ts.map +1 -0
- package/dist/certification/report.js +38 -0
- package/dist/certification/report.js.map +1 -0
- package/dist/certification/runner.d.ts +3 -0
- package/dist/certification/runner.d.ts.map +1 -0
- package/dist/certification/runner.js +299 -0
- package/dist/certification/runner.js.map +1 -0
- package/dist/certification/runtime.d.ts +11 -0
- package/dist/certification/runtime.d.ts.map +1 -0
- package/dist/certification/runtime.js +60 -0
- package/dist/certification/runtime.js.map +1 -0
- package/dist/certification/types.d.ts +73 -0
- package/dist/certification/types.d.ts.map +1 -0
- package/dist/certification/types.js +2 -0
- package/dist/certification/types.js.map +1 -0
- package/dist/cli.js +70 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/certify.d.ts +18 -0
- package/dist/commands/certify.d.ts.map +1 -0
- package/dist/commands/certify.js +27 -0
- package/dist/commands/certify.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +13 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts +5 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +9 -3
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/security-snapshot.d.ts +24 -0
- package/dist/commands/security-snapshot.d.ts.map +1 -0
- package/dist/commands/security-snapshot.js +113 -0
- package/dist/commands/security-snapshot.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/_scaffold.d.ts +2 -1
- package/dist/integrations/_scaffold.d.ts.map +1 -1
- package/dist/integrations/_scaffold.js +36 -13
- package/dist/integrations/_scaffold.js.map +1 -1
- package/dist/integrations/_simple-scaffold.d.ts +5 -2
- package/dist/integrations/_simple-scaffold.d.ts.map +1 -1
- package/dist/integrations/_simple-scaffold.js +3 -0
- package/dist/integrations/_simple-scaffold.js.map +1 -1
- package/dist/integrations/dotnet.d.ts.map +1 -1
- package/dist/integrations/dotnet.js +3 -0
- package/dist/integrations/dotnet.js.map +1 -1
- package/dist/integrations/expo/detect.d.ts +13 -0
- package/dist/integrations/expo/detect.d.ts.map +1 -0
- package/dist/integrations/expo/detect.js +38 -0
- package/dist/integrations/expo/detect.js.map +1 -0
- package/dist/integrations/expo/doctor.d.ts +6 -0
- package/dist/integrations/expo/doctor.d.ts.map +1 -0
- package/dist/integrations/expo/doctor.js +136 -0
- package/dist/integrations/expo/doctor.js.map +1 -0
- package/dist/integrations/expo/files.d.ts +15 -0
- package/dist/integrations/expo/files.d.ts.map +1 -0
- package/dist/integrations/expo/files.js +62 -0
- package/dist/integrations/expo/files.js.map +1 -0
- package/dist/integrations/expo/index.d.ts +24 -0
- package/dist/integrations/expo/index.d.ts.map +1 -0
- package/dist/integrations/expo/index.js +68 -0
- package/dist/integrations/expo/index.js.map +1 -0
- package/dist/integrations/expo/manifest.d.ts +3 -0
- package/dist/integrations/expo/manifest.d.ts.map +1 -0
- package/dist/integrations/expo/manifest.js +39 -0
- package/dist/integrations/expo/manifest.js.map +1 -0
- package/dist/integrations/expo/patch.d.ts +13 -0
- package/dist/integrations/expo/patch.d.ts.map +1 -0
- package/dist/integrations/expo/patch.js +215 -0
- package/dist/integrations/expo/patch.js.map +1 -0
- package/dist/integrations/expo/uninstall.d.ts +4 -0
- package/dist/integrations/expo/uninstall.d.ts.map +1 -0
- package/dist/integrations/expo/uninstall.js +77 -0
- package/dist/integrations/expo/uninstall.js.map +1 -0
- package/dist/integrations/expo.d.ts +8 -1
- package/dist/integrations/expo.d.ts.map +1 -1
- package/dist/integrations/expo.js +8 -11
- package/dist/integrations/expo.js.map +1 -1
- package/dist/integrations/fastify/detect.d.ts +3 -0
- package/dist/integrations/fastify/detect.d.ts.map +1 -0
- package/dist/integrations/fastify/detect.js +12 -0
- package/dist/integrations/fastify/detect.js.map +1 -0
- package/dist/integrations/fastify/doctor.d.ts +3 -0
- package/dist/integrations/fastify/doctor.d.ts.map +1 -0
- package/dist/integrations/fastify/doctor.js +81 -0
- package/dist/integrations/fastify/doctor.js.map +1 -0
- package/dist/integrations/fastify/files.d.ts +17 -0
- package/dist/integrations/fastify/files.d.ts.map +1 -0
- package/dist/integrations/fastify/files.js +51 -0
- package/dist/integrations/fastify/files.js.map +1 -0
- package/dist/integrations/fastify/index.d.ts +3 -0
- package/dist/integrations/fastify/index.d.ts.map +1 -0
- package/dist/integrations/fastify/index.js +47 -0
- package/dist/integrations/fastify/index.js.map +1 -0
- package/dist/integrations/fastify/manifest.d.ts +3 -0
- package/dist/integrations/fastify/manifest.d.ts.map +1 -0
- package/dist/integrations/fastify/manifest.js +34 -0
- package/dist/integrations/fastify/manifest.js.map +1 -0
- package/dist/integrations/fastify/patch.d.ts +27 -0
- package/dist/integrations/fastify/patch.d.ts.map +1 -0
- package/dist/integrations/fastify/patch.js +91 -0
- package/dist/integrations/fastify/patch.js.map +1 -0
- package/dist/integrations/fastify/uninstall.d.ts +4 -0
- package/dist/integrations/fastify/uninstall.d.ts.map +1 -0
- package/dist/integrations/fastify/uninstall.js +18 -0
- package/dist/integrations/fastify/uninstall.js.map +1 -0
- package/dist/integrations/fastify.d.ts +5 -1
- package/dist/integrations/fastify.d.ts.map +1 -1
- package/dist/integrations/fastify.js +5 -9
- package/dist/integrations/fastify.js.map +1 -1
- package/dist/integrations/flutter.d.ts.map +1 -1
- package/dist/integrations/flutter.js +3 -0
- package/dist/integrations/flutter.js.map +1 -1
- package/dist/integrations/go/index.d.ts +3 -0
- package/dist/integrations/go/index.d.ts.map +1 -0
- package/dist/integrations/go/index.js +199 -0
- package/dist/integrations/go/index.js.map +1 -0
- package/dist/integrations/go.d.ts.map +1 -1
- package/dist/integrations/go.js +5 -2
- package/dist/integrations/go.js.map +1 -1
- package/dist/integrations/java/index.d.ts +3 -0
- package/dist/integrations/java/index.d.ts.map +1 -0
- package/dist/integrations/java/index.js +472 -0
- package/dist/integrations/java/index.js.map +1 -0
- package/dist/integrations/java.d.ts.map +1 -1
- package/dist/integrations/java.js +5 -2
- package/dist/integrations/java.js.map +1 -1
- package/dist/integrations/js/manifest.d.ts.map +1 -1
- package/dist/integrations/js/manifest.js +3 -0
- package/dist/integrations/js/manifest.js.map +1 -1
- package/dist/integrations/nestjs/detect.d.ts +3 -0
- package/dist/integrations/nestjs/detect.d.ts.map +1 -0
- package/dist/integrations/nestjs/detect.js +12 -0
- package/dist/integrations/nestjs/detect.js.map +1 -0
- package/dist/integrations/nestjs/doctor.d.ts +3 -0
- package/dist/integrations/nestjs/doctor.d.ts.map +1 -0
- package/dist/integrations/nestjs/doctor.js +76 -0
- package/dist/integrations/nestjs/doctor.js.map +1 -0
- package/dist/integrations/nestjs/files.d.ts +18 -0
- package/dist/integrations/nestjs/files.d.ts.map +1 -0
- package/dist/integrations/nestjs/files.js +39 -0
- package/dist/integrations/nestjs/files.js.map +1 -0
- package/dist/integrations/nestjs/index.d.ts +3 -0
- package/dist/integrations/nestjs/index.d.ts.map +1 -0
- package/dist/integrations/nestjs/index.js +43 -0
- package/dist/integrations/nestjs/index.js.map +1 -0
- package/dist/integrations/nestjs/manifest.d.ts +3 -0
- package/dist/integrations/nestjs/manifest.d.ts.map +1 -0
- package/dist/integrations/nestjs/manifest.js +32 -0
- package/dist/integrations/nestjs/manifest.js.map +1 -0
- package/dist/integrations/nestjs/patch.d.ts +25 -0
- package/dist/integrations/nestjs/patch.d.ts.map +1 -0
- package/dist/integrations/nestjs/patch.js +66 -0
- package/dist/integrations/nestjs/patch.js.map +1 -0
- package/dist/integrations/nestjs/uninstall.d.ts +4 -0
- package/dist/integrations/nestjs/uninstall.d.ts.map +1 -0
- package/dist/integrations/nestjs/uninstall.js +18 -0
- package/dist/integrations/nestjs/uninstall.js.map +1 -0
- package/dist/integrations/nestjs.d.ts +5 -1
- package/dist/integrations/nestjs.d.ts.map +1 -1
- package/dist/integrations/nestjs.js +5 -9
- package/dist/integrations/nestjs.js.map +1 -1
- package/dist/integrations/next/index.js +2 -2
- package/dist/integrations/next/index.js.map +1 -1
- package/dist/integrations/next/manifest.d.ts.map +1 -1
- package/dist/integrations/next/manifest.js +4 -1
- package/dist/integrations/next/manifest.js.map +1 -1
- package/dist/integrations/next/patch.js +8 -3
- package/dist/integrations/next/patch.js.map +1 -1
- package/dist/integrations/next/uninstall.d.ts.map +1 -1
- package/dist/integrations/next/uninstall.js +10 -1
- package/dist/integrations/next/uninstall.js.map +1 -1
- package/dist/integrations/otel.d.ts.map +1 -1
- package/dist/integrations/otel.js +4 -1
- package/dist/integrations/otel.js.map +1 -1
- package/dist/integrations/php.d.ts.map +1 -1
- package/dist/integrations/php.js +16 -3
- package/dist/integrations/php.js.map +1 -1
- package/dist/integrations/python/index.d.ts +3 -0
- package/dist/integrations/python/index.d.ts.map +1 -0
- package/dist/integrations/python/index.js +222 -0
- package/dist/integrations/python/index.js.map +1 -0
- package/dist/integrations/python.d.ts.map +1 -1
- package/dist/integrations/python.js +5 -2
- package/dist/integrations/python.js.map +1 -1
- package/dist/integrations/react/doctor.d.ts.map +1 -1
- package/dist/integrations/react/doctor.js +41 -8
- package/dist/integrations/react/doctor.js.map +1 -1
- package/dist/integrations/react/index.d.ts.map +1 -1
- package/dist/integrations/react/index.js +1 -4
- package/dist/integrations/react/index.js.map +1 -1
- package/dist/integrations/react/manifest.d.ts.map +1 -1
- package/dist/integrations/react/manifest.js +4 -1
- package/dist/integrations/react/manifest.js.map +1 -1
- package/dist/integrations/react/patch.d.ts.map +1 -1
- package/dist/integrations/react/patch.js +120 -8
- package/dist/integrations/react/patch.js.map +1 -1
- package/dist/integrations/react/uninstall.d.ts.map +1 -1
- package/dist/integrations/react/uninstall.js +20 -1
- package/dist/integrations/react/uninstall.js.map +1 -1
- package/dist/integrations/react-native.d.ts.map +1 -1
- package/dist/integrations/react-native.js +3 -0
- package/dist/integrations/react-native.js.map +1 -1
- package/dist/integrations/ruby.d.ts.map +1 -1
- package/dist/integrations/ruby.js +3 -0
- package/dist/integrations/ruby.js.map +1 -1
- package/dist/output/human.d.ts.map +1 -1
- package/dist/output/human.js +38 -7
- package/dist/output/human.js.map +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +9 -23
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/manifest.d.ts +8 -0
- package/dist/registry/manifest.d.ts.map +1 -1
- package/dist/security-snapshot/builder.d.ts +3 -0
- package/dist/security-snapshot/builder.d.ts.map +1 -0
- package/dist/security-snapshot/builder.js +343 -0
- package/dist/security-snapshot/builder.js.map +1 -0
- package/dist/security-snapshot/client.d.ts +3 -0
- package/dist/security-snapshot/client.d.ts.map +1 -0
- package/dist/security-snapshot/client.js +38 -0
- package/dist/security-snapshot/client.js.map +1 -0
- package/dist/security-snapshot/index.d.ts +4 -0
- package/dist/security-snapshot/index.d.ts.map +1 -0
- package/dist/security-snapshot/index.js +3 -0
- package/dist/security-snapshot/index.js.map +1 -0
- package/dist/security-snapshot/types.d.ts +57 -0
- package/dist/security-snapshot/types.d.ts.map +1 -0
- package/dist/security-snapshot/types.js +2 -0
- package/dist/security-snapshot/types.js.map +1 -0
- package/dist/sourcemaps/next.js +3 -3
- package/dist/sourcemaps/next.js.map +1 -1
- package/dist/sourcemaps/vite.d.ts.map +1 -1
- package/dist/sourcemaps/vite.js +92 -9
- package/dist/sourcemaps/vite.js.map +1 -1
- package/dist/util/wizard-version.d.ts +1 -1
- package/dist/util/wizard-version.js +1 -1
- package/docs/architecture/v02-java-host-fix-spec.md +4 -8
- package/docs/architecture/v02-sourcemaps-e2e-spec.md +1 -1
- package/docs/beta/README.md +17 -0
- package/docs/beta/ci.md +122 -0
- package/docs/beta/config.md +124 -0
- package/docs/beta/doctor.md +79 -0
- package/docs/beta/expo.md +69 -0
- package/docs/beta/fastify.md +62 -0
- package/docs/beta/known-limitations.md +93 -0
- package/docs/beta/nestjs.md +69 -0
- package/docs/beta/next.md +76 -0
- package/docs/beta/node.md +60 -0
- package/docs/beta/privacy.md +99 -0
- package/docs/beta/quickstart.md +89 -0
- package/docs/beta/react.md +91 -0
- package/docs/beta/reliability.md +33 -0
- package/docs/beta/restore.md +84 -0
- package/docs/beta/troubleshooting.md +133 -0
- package/docs/errors.md +88 -0
- package/package.json +23 -5
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { writeStandardEnv } from '../_shared.js';
|
|
2
|
+
import { patchJsonFile } from '../../patchers/json-file.js';
|
|
3
|
+
import { patchJsModule, ensureImport } from '../../patchers/js-ast.js';
|
|
4
|
+
import { appendManagedBlock } from '../../patchers/source-block.js';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { parseModule } from 'magicast';
|
|
7
|
+
import { log } from '../../util/log.js';
|
|
8
|
+
import { locateAppConfig, locateAppEntry, locateAppJson } from './files.js';
|
|
9
|
+
const PKG = '@allstak/react-native';
|
|
10
|
+
/**
|
|
11
|
+
* The plugin reference shape the SDK exposes. The Expo CLI accepts either
|
|
12
|
+
* the bare module specifier ("@allstak/react-native") which it resolves to
|
|
13
|
+
* `node_modules/@allstak/react-native/app.plugin.js`, or an explicit
|
|
14
|
+
* `["@allstak/react-native/app.plugin"]` form. We use the bare form so the
|
|
15
|
+
* SDK can move its plugin entry point without breaking us.
|
|
16
|
+
*/
|
|
17
|
+
const PLUGIN_SPECIFIER = '@allstak/react-native';
|
|
18
|
+
export async function patchExpo(ctx, tx) {
|
|
19
|
+
await writeStandardEnv(ctx, tx, '.env');
|
|
20
|
+
await patchAppJson(ctx, tx);
|
|
21
|
+
await patchAppEntry(ctx, tx);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Idempotent app.json patch. Adds `PLUGIN_SPECIFIER` to `expo.plugins[]`
|
|
25
|
+
* exactly once. Re-runs are no-ops because we check membership before push.
|
|
26
|
+
*
|
|
27
|
+
* If the project uses `app.config.{js,ts,mjs}` instead, we leave it alone
|
|
28
|
+
* and emit a managed-block hint at the bottom (those configs may include
|
|
29
|
+
* dynamic logic; rewriting them is unsafe).
|
|
30
|
+
*/
|
|
31
|
+
async function patchAppJson(ctx, tx) {
|
|
32
|
+
const jsonPath = locateAppJson(ctx.projectRoot);
|
|
33
|
+
if (jsonPath) {
|
|
34
|
+
await patchJsonFile(tx, jsonPath, (root) => {
|
|
35
|
+
// Cast through `unknown` because the `JsonObject` type in our patcher is
|
|
36
|
+
// strictly typed (no Record<string, any>) and Expo's plugins[] entries
|
|
37
|
+
// can be either `string` or `[string, options]`. We've narrowed on read
|
|
38
|
+
// so the cast is safe at runtime.
|
|
39
|
+
const r = root;
|
|
40
|
+
const expo = r.expo ?? {};
|
|
41
|
+
const plugins = Array.isArray(expo.plugins) ? [...expo.plugins] : [];
|
|
42
|
+
const alreadyPresent = plugins.some((p) => {
|
|
43
|
+
if (typeof p === 'string')
|
|
44
|
+
return p === PLUGIN_SPECIFIER;
|
|
45
|
+
if (Array.isArray(p) && typeof p[0] === 'string')
|
|
46
|
+
return p[0] === PLUGIN_SPECIFIER;
|
|
47
|
+
return false;
|
|
48
|
+
});
|
|
49
|
+
if (!alreadyPresent)
|
|
50
|
+
plugins.push(PLUGIN_SPECIFIER);
|
|
51
|
+
expo.plugins = plugins;
|
|
52
|
+
r.expo = expo;
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const cfg = locateAppConfig(ctx.projectRoot);
|
|
57
|
+
if (!cfg) {
|
|
58
|
+
log.warn('No app.json or app.config.* found — Expo plugin wiring skipped.');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
await appendManagedBlock(tx, cfg, [
|
|
62
|
+
`// allstak-wizard: add the AllStak Expo plugin to the plugins array, e.g.:`,
|
|
63
|
+
`// export default ({ config }) => ({ ...config, plugins: [...(config.plugins ?? []), '${PLUGIN_SPECIFIER}'] });`,
|
|
64
|
+
`// (Wizard does not auto-mutate app.config.* because dynamic configs can include arbitrary code.)`,
|
|
65
|
+
].join('\n'), { style: 'slash', validateJs: true });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Patch the App entry. Prefer real root wrapping for normal Expo App.tsx
|
|
69
|
+
* entries. Fall back to a managed-block only when the render tree is too
|
|
70
|
+
* dynamic to mutate safely.
|
|
71
|
+
*/
|
|
72
|
+
async function patchAppEntry(ctx, tx) {
|
|
73
|
+
const entry = locateAppEntry(ctx.projectRoot);
|
|
74
|
+
if (!entry) {
|
|
75
|
+
log.warn('No App.tsx/App.js found — provider wiring hint skipped. Run repair after creating the entry file.');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
await patchJsModule(tx, entry, (mod) => {
|
|
79
|
+
ensureImport(mod, { from: PKG, named: ['AllStakProvider'] });
|
|
80
|
+
});
|
|
81
|
+
const current = readFileSync(entry, 'utf8');
|
|
82
|
+
if (isExpoEntryAlreadyIntegrated(current)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const patched = patchExpoAppRoot(current, ctx);
|
|
86
|
+
if (patched.changed) {
|
|
87
|
+
await tx.write(entry, patched.code, async (_path, content) => {
|
|
88
|
+
parseModule(content);
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const block = [
|
|
93
|
+
`// allstak-wizard: manual review required.`,
|
|
94
|
+
`// The wizard imported AllStakProvider but could not safely wrap the Expo root component.`,
|
|
95
|
+
`// Wrap your existing root tree in <AllStakMobileRoot>:`,
|
|
96
|
+
`//`,
|
|
97
|
+
`// <AllStakMobileRoot>{/* existing app */}</AllStakMobileRoot>`,
|
|
98
|
+
`//`,
|
|
99
|
+
`// Note: read the API key via EXPO_PUBLIC_* (in app.config.js or .env.local`,
|
|
100
|
+
`// honoured by Expo). Do NOT hardcode keys in source.`,
|
|
101
|
+
].join('\n');
|
|
102
|
+
await appendManagedBlock(tx, entry, block, { style: 'slash', validateJs: true });
|
|
103
|
+
}
|
|
104
|
+
function isExpoEntryAlreadyIntegrated(src) {
|
|
105
|
+
const semantic = stripComments(src);
|
|
106
|
+
return semantic.includes('<AllStakProvider') || semantic.includes('<AllStakMobileRoot') || /AllStak\.init\s*\(/.test(semantic);
|
|
107
|
+
}
|
|
108
|
+
function patchExpoAppRoot(src, ctx) {
|
|
109
|
+
if (isExpoEntryAlreadyIntegrated(src))
|
|
110
|
+
return { changed: false, code: src };
|
|
111
|
+
const fnStart = src.search(/export\s+default\s+function\s+App\s*\(/);
|
|
112
|
+
if (fnStart < 0)
|
|
113
|
+
return { changed: false, code: src };
|
|
114
|
+
const fnOpen = src.indexOf('{', fnStart);
|
|
115
|
+
const fnClose = findMatching(src, fnOpen, '{', '}');
|
|
116
|
+
if (fnOpen < 0 || fnClose < 0)
|
|
117
|
+
return { changed: false, code: src };
|
|
118
|
+
const body = src.slice(fnOpen + 1, fnClose);
|
|
119
|
+
const bodyOffset = fnOpen + 1;
|
|
120
|
+
const returnMatch = /\breturn\s*\(/.exec(body);
|
|
121
|
+
if (!returnMatch)
|
|
122
|
+
return { changed: false, code: src };
|
|
123
|
+
const returnOpen = bodyOffset + returnMatch.index + returnMatch[0].lastIndexOf('(');
|
|
124
|
+
const returnClose = findMatching(src, returnOpen, '(', ')');
|
|
125
|
+
if (returnClose < 0 || returnClose > fnClose)
|
|
126
|
+
return { changed: false, code: src };
|
|
127
|
+
const renderBody = src.slice(returnOpen + 1, returnClose).trim();
|
|
128
|
+
if (!renderBody)
|
|
129
|
+
return { changed: false, code: src };
|
|
130
|
+
let code = ensureReactNodeImport(src);
|
|
131
|
+
code = ensureAllStakMobileRootComponent(code, ctx);
|
|
132
|
+
const adjustedFnStart = code.search(/export\s+default\s+function\s+App\s*\(/);
|
|
133
|
+
const adjustedFnOpen = code.indexOf('{', adjustedFnStart);
|
|
134
|
+
const adjustedFnClose = findMatching(code, adjustedFnOpen, '{', '}');
|
|
135
|
+
const adjustedBody = code.slice(adjustedFnOpen + 1, adjustedFnClose);
|
|
136
|
+
const adjustedReturnMatch = /\breturn\s*\(/.exec(adjustedBody);
|
|
137
|
+
if (!adjustedReturnMatch)
|
|
138
|
+
return { changed: false, code: src };
|
|
139
|
+
const adjustedReturnOpen = adjustedFnOpen + 1 + adjustedReturnMatch.index + adjustedReturnMatch[0].lastIndexOf('(');
|
|
140
|
+
const adjustedReturnClose = findMatching(code, adjustedReturnOpen, '(', ')');
|
|
141
|
+
if (adjustedReturnClose < 0 || adjustedReturnClose > adjustedFnClose)
|
|
142
|
+
return { changed: false, code: src };
|
|
143
|
+
const adjustedRenderBody = code.slice(adjustedReturnOpen + 1, adjustedReturnClose).trim();
|
|
144
|
+
const wrapped = `\n <AllStakMobileRoot>\n ${adjustedRenderBody}\n </AllStakMobileRoot>\n `;
|
|
145
|
+
code = `${code.slice(0, adjustedReturnOpen + 1)}${wrapped}${code.slice(adjustedReturnClose)}`;
|
|
146
|
+
return { changed: code !== src, code };
|
|
147
|
+
}
|
|
148
|
+
function ensureReactNodeImport(src) {
|
|
149
|
+
if (/import\s+type\s+\{\s*ReactNode\s*\}\s+from\s+['"]react['"]/.test(src))
|
|
150
|
+
return src;
|
|
151
|
+
if (/from\s+['"]react['"]/.test(src) && /\bReactNode\b/.test(src))
|
|
152
|
+
return src;
|
|
153
|
+
return `import type { ReactNode } from 'react';\n${src}`;
|
|
154
|
+
}
|
|
155
|
+
function ensureAllStakMobileRootComponent(src, ctx) {
|
|
156
|
+
if (src.includes('function AllStakMobileRoot('))
|
|
157
|
+
return src;
|
|
158
|
+
const component = [
|
|
159
|
+
'',
|
|
160
|
+
'function AllStakMobileRoot({ children }: { children: ReactNode }) {',
|
|
161
|
+
' const apiKey = process.env.EXPO_PUBLIC_ALLSTAK_API_KEY ?? process.env.ALLSTAK_API_KEY;',
|
|
162
|
+
' if (!apiKey) return <>{children}</>;',
|
|
163
|
+
' return (',
|
|
164
|
+
' <AllStakProvider',
|
|
165
|
+
' apiKey={apiKey}',
|
|
166
|
+
' host={process.env.EXPO_PUBLIC_ALLSTAK_HOST}',
|
|
167
|
+
` environment={process.env.EXPO_PUBLIC_ALLSTAK_ENVIRONMENT ?? '${ctx.environment}'}`,
|
|
168
|
+
` release={process.env.EXPO_PUBLIC_ALLSTAK_RELEASE ?? '${ctx.release ?? ''}'}`,
|
|
169
|
+
' enableHttpTracking',
|
|
170
|
+
' tracesSampleRate={1}',
|
|
171
|
+
' >',
|
|
172
|
+
' {children}',
|
|
173
|
+
' </AllStakProvider>',
|
|
174
|
+
' );',
|
|
175
|
+
'}',
|
|
176
|
+
'',
|
|
177
|
+
].join('\n');
|
|
178
|
+
const appIndex = src.search(/export\s+default\s+function\s+App\s*\(/);
|
|
179
|
+
if (appIndex < 0)
|
|
180
|
+
return src;
|
|
181
|
+
return `${src.slice(0, appIndex)}${component}${src.slice(appIndex)}`;
|
|
182
|
+
}
|
|
183
|
+
function findMatching(src, openIndex, openChar, closeChar) {
|
|
184
|
+
if (openIndex < 0 || src[openIndex] !== openChar)
|
|
185
|
+
return -1;
|
|
186
|
+
let depth = 0;
|
|
187
|
+
let quote = null;
|
|
188
|
+
for (let i = openIndex; i < src.length; i += 1) {
|
|
189
|
+
const ch = src[i];
|
|
190
|
+
const prev = src[i - 1];
|
|
191
|
+
if (quote) {
|
|
192
|
+
if (ch === quote && prev !== '\\')
|
|
193
|
+
quote = null;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
197
|
+
quote = ch;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (ch === openChar)
|
|
201
|
+
depth += 1;
|
|
202
|
+
if (ch === closeChar) {
|
|
203
|
+
depth -= 1;
|
|
204
|
+
if (depth === 0)
|
|
205
|
+
return i;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return -1;
|
|
209
|
+
}
|
|
210
|
+
function stripComments(src) {
|
|
211
|
+
return src.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
212
|
+
}
|
|
213
|
+
// Re-export PLUGIN_SPECIFIER for tests/uninstall to share.
|
|
214
|
+
export { PLUGIN_SPECIFIER };
|
|
215
|
+
//# sourceMappingURL=patch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../src/integrations/expo/patch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM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AAW;IAChC,OAAO,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAED,2DAA2D;AAC3D,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../../src/integrations/expo/uninstall.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAU7D,wBAAsB,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CtF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { parseModule } from 'magicast';
|
|
4
|
+
import { runPackageUninstall, removeStandardEnv } from '../_shared.js';
|
|
5
|
+
import { patchJsonFile } from '../../patchers/json-file.js';
|
|
6
|
+
import { patchJsModule, removeImport } from '../../patchers/js-ast.js';
|
|
7
|
+
import { removeManagedSourceBlock } from '../../patchers/source-block.js';
|
|
8
|
+
import { locateAppConfig, locateAppEntry, locateAppJson } from './files.js';
|
|
9
|
+
import { PLUGIN_SPECIFIER } from './patch.js';
|
|
10
|
+
const PKG = '@allstak/react-native';
|
|
11
|
+
export async function uninstallExpo(ctx, tx) {
|
|
12
|
+
await removeStandardEnv(tx, resolve(ctx.projectRoot, '.env'));
|
|
13
|
+
// Remove the plugin reference from app.json (only if it was added by us /
|
|
14
|
+
// matches our specifier). Idempotent — missing plugin entry is no-op.
|
|
15
|
+
const jsonPath = locateAppJson(ctx.projectRoot);
|
|
16
|
+
if (jsonPath) {
|
|
17
|
+
await patchJsonFile(tx, jsonPath, (root) => {
|
|
18
|
+
const r = root;
|
|
19
|
+
const expo = r.expo;
|
|
20
|
+
if (!expo || !Array.isArray(expo.plugins))
|
|
21
|
+
return;
|
|
22
|
+
const filtered = expo.plugins.filter((p) => {
|
|
23
|
+
if (typeof p === 'string')
|
|
24
|
+
return p !== PLUGIN_SPECIFIER;
|
|
25
|
+
if (Array.isArray(p) && typeof p[0] === 'string')
|
|
26
|
+
return p[0] !== PLUGIN_SPECIFIER;
|
|
27
|
+
return true;
|
|
28
|
+
});
|
|
29
|
+
if (filtered.length === 0) {
|
|
30
|
+
// Drop the plugins array entirely if we emptied it. Keeps the file
|
|
31
|
+
// tidy but doesn't touch other Expo config.
|
|
32
|
+
delete expo.plugins;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
expo.plugins = filtered;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// Remove the wizard's managed-block hint from app.config.* if it exists.
|
|
40
|
+
const cfg = locateAppConfig(ctx.projectRoot);
|
|
41
|
+
if (cfg) {
|
|
42
|
+
await removeManagedSourceBlock(tx, cfg, 'slash');
|
|
43
|
+
}
|
|
44
|
+
// Reverse the entry patches.
|
|
45
|
+
const entry = locateAppEntry(ctx.projectRoot);
|
|
46
|
+
if (entry) {
|
|
47
|
+
await removeManagedSourceBlock(tx, entry, 'slash');
|
|
48
|
+
const current = readFileSync(entry, 'utf8');
|
|
49
|
+
const cleaned = removeExpoRootWrapper(current);
|
|
50
|
+
if (cleaned !== current) {
|
|
51
|
+
await tx.write(entry, cleaned, async (_path, content) => {
|
|
52
|
+
parseModule(content);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
await patchJsModule(tx, entry, (mod) => removeImport(mod, PKG));
|
|
56
|
+
}
|
|
57
|
+
await runPackageUninstall(ctx, [PKG]);
|
|
58
|
+
}
|
|
59
|
+
function removeExpoRootWrapper(src) {
|
|
60
|
+
let out = unwrapMobileRoot(src);
|
|
61
|
+
out = out.replace(/\nfunction AllStakMobileRoot\([\s\S]*?\nexport default function App\(/, '\nexport default function App(');
|
|
62
|
+
out = out.replace(/^import\s+type\s+\{\s*ReactNode\s*\}\s+from\s+['"]react['"];\n/m, '');
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
function unwrapMobileRoot(src) {
|
|
66
|
+
const openTag = '<AllStakMobileRoot>';
|
|
67
|
+
const closeTag = '</AllStakMobileRoot>';
|
|
68
|
+
const open = src.indexOf(openTag);
|
|
69
|
+
const close = src.indexOf(closeTag);
|
|
70
|
+
if (open < 0 || close < 0 || close < open)
|
|
71
|
+
return src;
|
|
72
|
+
const before = src.slice(0, open);
|
|
73
|
+
const inner = src.slice(open + openTag.length, close).trim();
|
|
74
|
+
const after = src.slice(close + closeTag.length);
|
|
75
|
+
return `${before}${inner}${after}`;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=uninstall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../src/integrations/expo/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,GAAG,GAAG,uBAAuB,CAAC;AAEpC,MAAM,CAAC,KAAK,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G,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC;IACtD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Re-export the real Expo integration. The simple-scaffold previously lived
|
|
3
|
+
* here; the implementation has been split into `src/integrations/expo/`.
|
|
4
|
+
*
|
|
5
|
+
* This file is kept (rather than letting the registry import directly from
|
|
6
|
+
* `./expo/index.js`) so removing it later requires only one registry edit.
|
|
7
|
+
*/
|
|
8
|
+
export { expoIntegration } from './expo/index.js';
|
|
2
9
|
//# sourceMappingURL=expo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo.d.ts","sourceRoot":"","sources":["../../src/integrations/expo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expo.d.ts","sourceRoot":"","sources":["../../src/integrations/expo.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
supportedPackageManagers: ['npm', 'pnpm', 'yarn', 'yarn-berry', 'bun'],
|
|
10
|
-
reason: 'Expo config-plugin path is partially scaffolded but iOS/Android native build verification has not been performed in this wizard release. Wire-up happens via app.json / app.config.* additions; bare RN is intentionally refused.',
|
|
11
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Re-export the real Expo integration. The simple-scaffold previously lived
|
|
3
|
+
* here; the implementation has been split into `src/integrations/expo/`.
|
|
4
|
+
*
|
|
5
|
+
* This file is kept (rather than letting the registry import directly from
|
|
6
|
+
* `./expo/index.js`) so removing it later requires only one registry edit.
|
|
7
|
+
*/
|
|
8
|
+
export { expoIntegration } from './expo/index.js';
|
|
12
9
|
//# sourceMappingURL=expo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo.js","sourceRoot":"","sources":["../../src/integrations/expo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"expo.js","sourceRoot":"","sources":["../../src/integrations/expo.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/integrations/fastify/detect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIjF,wBAAsB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAMnF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { evaluateCompatibility } from '../../compat/engine.js';
|
|
2
|
+
import { fastifyManifest } from './manifest.js';
|
|
3
|
+
export async function detectFastify(ctx) {
|
|
4
|
+
const pj = ctx.detected.packageJson;
|
|
5
|
+
if (!pj)
|
|
6
|
+
return { ok: false, reason: 'no package.json found' };
|
|
7
|
+
const verdict = evaluateCompatibility(fastifyManifest, pj);
|
|
8
|
+
if (!verdict.ok)
|
|
9
|
+
return { ok: false, reason: verdict.reason };
|
|
10
|
+
return { ok: true };
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../../src/integrations/fastify/detect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAkB;IACpD,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC;IACpC,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAC;IAC/D,MAAM,OAAO,GAAG,qBAAqB,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IAC9D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/integrations/fastify/doctor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,yBAAyB,CAAC;AAKxF,wBAAsB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA8E7E"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { detectModuleSystem, locateFastifyEntry } from './files.js';
|
|
4
|
+
const PKG = '@allstak/fastify';
|
|
5
|
+
export async function doctorFastify(ctx) {
|
|
6
|
+
const checks = [];
|
|
7
|
+
const pj = ctx.detected.packageJson;
|
|
8
|
+
const installed = !!(pj?.dependencies?.[PKG] ?? pj?.devDependencies?.[PKG]);
|
|
9
|
+
checks.push({
|
|
10
|
+
name: 'sdk-installed',
|
|
11
|
+
status: installed ? 'pass' : 'fail',
|
|
12
|
+
detail: installed ? PKG : `${PKG} is not in dependencies`,
|
|
13
|
+
fix: installed ? undefined : 'Run: allstak-wizard -i fastify',
|
|
14
|
+
});
|
|
15
|
+
const envPath = resolve(ctx.projectRoot, '.env');
|
|
16
|
+
const envOk = existsSync(envPath) && readFileSync(envPath, 'utf8').includes('ALLSTAK_API_KEY');
|
|
17
|
+
checks.push({
|
|
18
|
+
name: 'env-vars',
|
|
19
|
+
status: envOk ? 'pass' : 'warn',
|
|
20
|
+
detail: envOk ? '.env has ALLSTAK_API_KEY' : 'ALLSTAK_API_KEY not found in .env',
|
|
21
|
+
});
|
|
22
|
+
const entry = locateFastifyEntry(ctx);
|
|
23
|
+
if (entry) {
|
|
24
|
+
const src = readFileSync(entry, 'utf8');
|
|
25
|
+
const moduleSystem = detectModuleSystem(ctx, entry);
|
|
26
|
+
if (moduleSystem === 'esm') {
|
|
27
|
+
const hasImport = /allstakFastify/.test(src);
|
|
28
|
+
checks.push({
|
|
29
|
+
name: 'entry-import',
|
|
30
|
+
status: hasImport ? 'pass' : 'fail',
|
|
31
|
+
detail: hasImport ? entry : `${entry} does not import allstakFastify`,
|
|
32
|
+
fix: hasImport ? undefined : 'Run: allstak-wizard repair -i fastify',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
checks.push({
|
|
37
|
+
name: 'entry-import',
|
|
38
|
+
status: 'skip',
|
|
39
|
+
detail: 'CJS entry — wizard does not AST-inject require() (see managed-block hint)',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const hasBlock = /allstak-wizard:/.test(src);
|
|
43
|
+
checks.push({
|
|
44
|
+
name: 'entry-hint',
|
|
45
|
+
status: hasBlock ? 'pass' : 'warn',
|
|
46
|
+
detail: hasBlock ? 'managed-block hint present' : 'managed-block hint missing',
|
|
47
|
+
});
|
|
48
|
+
// Strip line comments so we don't match the wizard's own managed-block
|
|
49
|
+
// hint, which demonstrates the register call inside `//` comments.
|
|
50
|
+
const liveSrc = src.replace(/^\s*\/\/.*$/gm, '');
|
|
51
|
+
const callPresent = /\bregister\s*\(\s*allstakFastify\b/.test(liveSrc);
|
|
52
|
+
checks.push({
|
|
53
|
+
name: 'plugin-registered',
|
|
54
|
+
status: callPresent ? 'pass' : 'warn',
|
|
55
|
+
detail: callPresent
|
|
56
|
+
? 'app.register(allstakFastify, ...) detected'
|
|
57
|
+
: 'No `app.register(allstakFastify, ...)` call detected — wire it manually per the managed-block hint',
|
|
58
|
+
fix: callPresent ? undefined : 'See managed-block in your entry file or docs/beta/fastify.md',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
checks.push({
|
|
63
|
+
name: 'entry-detected',
|
|
64
|
+
status: 'fail',
|
|
65
|
+
detail: 'No Fastify entry file found (tried package.json scripts/main + conventional locations)',
|
|
66
|
+
fix: 'Confirm this is a Fastify project; standard entry is src/server.ts or src/index.ts',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
checks.push({
|
|
70
|
+
name: 'source-maps',
|
|
71
|
+
status: 'skip',
|
|
72
|
+
detail: 'Fastify source-map upload not wired by wizard in v0.1 (deferred to v0.2).',
|
|
73
|
+
});
|
|
74
|
+
const summary = checks.some((c) => c.status === 'fail')
|
|
75
|
+
? 'broken'
|
|
76
|
+
: checks.some((c) => c.status === 'warn')
|
|
77
|
+
? 'degraded'
|
|
78
|
+
: 'ok';
|
|
79
|
+
return { integration: 'fastify', checks, summary };
|
|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
import type { WizardContext } from '../../registry/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Locate the Fastify entry file.
|
|
4
|
+
*
|
|
5
|
+
* Priority: `package.json:scripts.start` (`node X.js` pattern), then
|
|
6
|
+
* `package.json:main`, then conventional locations. Fastify projects vary
|
|
7
|
+
* widely so we try a generous candidate list before giving up.
|
|
8
|
+
*/
|
|
9
|
+
export declare function locateFastifyEntry(ctx: WizardContext): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Best-effort module-system detection. Returns 'esm' when the entry uses
|
|
12
|
+
* import statements OR the project's `package.json:type === "module"`,
|
|
13
|
+
* 'cjs' otherwise. The hint we emit differs slightly between the two so
|
|
14
|
+
* users can paste it without converting.
|
|
15
|
+
*/
|
|
16
|
+
export declare function detectModuleSystem(ctx: WizardContext, entry: string): 'esm' | 'cjs';
|
|
17
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/integrations/fastify/files.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAuBpE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAWnF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Locate the Fastify entry file.
|
|
5
|
+
*
|
|
6
|
+
* Priority: `package.json:scripts.start` (`node X.js` pattern), then
|
|
7
|
+
* `package.json:main`, then conventional locations. Fastify projects vary
|
|
8
|
+
* widely so we try a generous candidate list before giving up.
|
|
9
|
+
*/
|
|
10
|
+
export function locateFastifyEntry(ctx) {
|
|
11
|
+
const pj = ctx.detected.packageJson;
|
|
12
|
+
const candidates = [];
|
|
13
|
+
if (pj?.scripts?.start) {
|
|
14
|
+
const m = /node\s+([^\s&]+)/.exec(pj.scripts.start);
|
|
15
|
+
if (m)
|
|
16
|
+
candidates.push(m[1]);
|
|
17
|
+
}
|
|
18
|
+
if (pj && pj.main) {
|
|
19
|
+
candidates.push(pj.main);
|
|
20
|
+
}
|
|
21
|
+
candidates.push('src/server.ts', 'src/server.js', 'src/server.mjs', 'src/index.ts', 'src/index.js', 'src/index.mjs', 'src/app.ts', 'src/app.js', 'server.ts', 'server.js', 'server.mjs', 'app.ts', 'app.js', 'index.ts', 'index.js', 'index.mjs');
|
|
22
|
+
for (const c of candidates) {
|
|
23
|
+
const full = resolve(ctx.projectRoot, c);
|
|
24
|
+
if (existsSync(full))
|
|
25
|
+
return full;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Best-effort module-system detection. Returns 'esm' when the entry uses
|
|
31
|
+
* import statements OR the project's `package.json:type === "module"`,
|
|
32
|
+
* 'cjs' otherwise. The hint we emit differs slightly between the two so
|
|
33
|
+
* users can paste it without converting.
|
|
34
|
+
*/
|
|
35
|
+
export function detectModuleSystem(ctx, entry) {
|
|
36
|
+
const pj = ctx.detected.packageJson;
|
|
37
|
+
if (pj?.type === 'module' || entry.endsWith('.mjs'))
|
|
38
|
+
return 'esm';
|
|
39
|
+
if (entry.endsWith('.cjs'))
|
|
40
|
+
return 'cjs';
|
|
41
|
+
try {
|
|
42
|
+
const src = readFileSync(entry, 'utf8');
|
|
43
|
+
if (/^\s*import\s+/m.test(src))
|
|
44
|
+
return 'esm';
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// ignore
|
|
48
|
+
}
|
|
49
|
+
return 'cjs';
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,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,CAAC,GAAkB,EAAE,KAAa;IAClE,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAuC,CAAC;IAChE,IAAI,EAAE,EAAE,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAClE,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACxC,IAAI,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/fastify/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAS3D,eAAO,MAAM,kBAAkB,EAAE,WA6ChC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { runPackageInstall } from '../_shared.js';
|
|
2
|
+
import { fastifyManifest } from './manifest.js';
|
|
3
|
+
import { detectFastify } from './detect.js';
|
|
4
|
+
import { patchFastify } from './patch.js';
|
|
5
|
+
import { uninstallFastify } from './uninstall.js';
|
|
6
|
+
import { doctorFastify } from './doctor.js';
|
|
7
|
+
import { detectModuleSystem, locateFastifyEntry } from './files.js';
|
|
8
|
+
export const fastifyIntegration = {
|
|
9
|
+
id: 'fastify',
|
|
10
|
+
manifest: fastifyManifest,
|
|
11
|
+
async detect(ctx) {
|
|
12
|
+
return detectFastify(ctx);
|
|
13
|
+
},
|
|
14
|
+
async plan(ctx) {
|
|
15
|
+
const lines = [];
|
|
16
|
+
lines.push(`install ${fastifyManifest.sdkPackage} (${ctx.pm})`);
|
|
17
|
+
lines.push(`write ALLSTAK_* to .env`);
|
|
18
|
+
const entry = locateFastifyEntry(ctx);
|
|
19
|
+
if (entry) {
|
|
20
|
+
const moduleSystem = detectModuleSystem(ctx, entry);
|
|
21
|
+
lines.push(`patch entry: ${entry} (${moduleSystem.toUpperCase()})`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
lines.push(`no Fastify entry detected — config-only run`);
|
|
25
|
+
}
|
|
26
|
+
return lines;
|
|
27
|
+
},
|
|
28
|
+
async install(ctx) {
|
|
29
|
+
await runPackageInstall(ctx, [fastifyManifest.sdkPackage]);
|
|
30
|
+
},
|
|
31
|
+
async patch(ctx, tx) {
|
|
32
|
+
await patchFastify(ctx, tx);
|
|
33
|
+
},
|
|
34
|
+
async validate(ctx) {
|
|
35
|
+
return doctorFastify(ctx);
|
|
36
|
+
},
|
|
37
|
+
async uninstall(ctx, tx) {
|
|
38
|
+
await uninstallFastify(ctx, tx);
|
|
39
|
+
},
|
|
40
|
+
async repair(ctx, tx) {
|
|
41
|
+
await patchFastify(ctx, tx);
|
|
42
|
+
},
|
|
43
|
+
async doctor(ctx) {
|
|
44
|
+
return doctorFastify(ctx);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=index.js.map
|