@aventara/cli 0.1.0-pilot.4 → 1.0.0-rc.0
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 +114 -0
- package/README.md +9 -4
- package/dist/cli.js +4 -0
- package/dist/command/command.parser.js +7 -0
- package/dist/run/command.runner.js +2 -0
- package/dist/run/init.orchestrator.js +33 -13
- package/dist/run/new.orchestrator.js +29 -11
- package/dist/run/step.reporter.js +87 -0
- package/package.json +4 -3
- package/dist/apply/app-module.anchor.d.ts +0 -24
- package/dist/apply/conflict.confirmer.d.ts +0 -15
- package/dist/apply/e2e-spec.anchor.d.ts +0 -18
- package/dist/apply/main-cors.anchor.d.ts +0 -50
- package/dist/apply/manifest.merger.d.ts +0 -51
- package/dist/aventara.bin.d.ts +0 -2
- package/dist/catalog/adapter.catalog.generated.d.ts +0 -20
- package/dist/catalog/catalog-entry.interface.d.ts +0 -54
- package/dist/catalog/catalog.matcher.d.ts +0 -40
- package/dist/catalog/range.reader.d.ts +0 -11
- package/dist/cli.d.ts +0 -29
- package/dist/command/command.parser.d.ts +0 -38
- package/dist/node-version.guard.d.ts +0 -8
- package/dist/plan/project.planner.d.ts +0 -53
- package/dist/project/package-manager.detector.d.ts +0 -5
- package/dist/project/project.inspector.d.ts +0 -32
- package/dist/project/service.detector.d.ts +0 -40
- package/dist/project/source.scanner.d.ts +0 -16
- package/dist/run/command.runner.d.ts +0 -15
- package/dist/run/init.orchestrator.d.ts +0 -27
- package/dist/run/new.orchestrator.d.ts +0 -20
- package/dist/run/scaffold.committer.d.ts +0 -28
- package/dist/templates/docs.links.d.ts +0 -8
- package/dist/templates/prisma7/prisma7.templates.d.ts +0 -34
- package/dist/templates/template.registry.d.ts +0 -152
- package/dist/wizard/answer.resolver.d.ts +0 -47
- package/dist/wizard/readline.prompter.d.ts +0 -22
- package/dist/wizard/wizard.questions.d.ts +0 -120
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const ADAPTER_CATALOG: readonly [{
|
|
2
|
-
readonly id: "prisma7";
|
|
3
|
-
readonly alias: "prisma7";
|
|
4
|
-
readonly adapterPackage: "@aventara/prisma7-adapter";
|
|
5
|
-
readonly orm: {
|
|
6
|
-
readonly family: "prisma";
|
|
7
|
-
readonly label: "Prisma";
|
|
8
|
-
readonly package: "@prisma/client";
|
|
9
|
-
readonly major: 7;
|
|
10
|
-
};
|
|
11
|
-
readonly range: "^7.10.0";
|
|
12
|
-
readonly familyPackages: readonly ["prisma", "@prisma/client", "@prisma/prisma7", "@prisma/orm-*"];
|
|
13
|
-
readonly providers: readonly ["sqlite", "postgresql"];
|
|
14
|
-
readonly drivers: {
|
|
15
|
-
readonly sqlite: "@prisma/adapter-better-sqlite3";
|
|
16
|
-
readonly postgresql: "@prisma/adapter-pg";
|
|
17
|
-
};
|
|
18
|
-
readonly generators: readonly ["prisma-client"];
|
|
19
|
-
readonly bin: "aventara-prisma7-generate";
|
|
20
|
-
}];
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { ADAPTER_CATALOG } from "./adapter.catalog.generated.js";
|
|
2
|
-
/**
|
|
3
|
-
* One entry per Aventara adapter package that exists: what the CLI may offer and
|
|
4
|
-
* what it must refuse, every value traced to that adapter's own manifest — its
|
|
5
|
-
* `aventara.adapter` declaration, its `peerDependencies` and its `bin`. The
|
|
6
|
-
* entries are **generated** at this package's build by
|
|
7
|
-
* `scripts/adapter-catalog.generator.ts` into `adapter.catalog.generated.ts` and
|
|
8
|
-
* never edited. The CLI holds no list of ORMs, majors, providers or drivers of its
|
|
9
|
-
* own.
|
|
10
|
-
*/
|
|
11
|
-
export type CatalogEntry = {
|
|
12
|
-
/**
|
|
13
|
-
* The adapter package's ORM stem, e.g. `prisma7`: the wizard's value and the
|
|
14
|
-
* templates' key.
|
|
15
|
-
*/
|
|
16
|
-
readonly id: string;
|
|
17
|
-
/**
|
|
18
|
-
* `aventara.adapter.alias`, e.g. `prisma7`: what `--orm` takes. Always
|
|
19
|
-
* `<orm><major>`, the generator refuses any other.
|
|
20
|
-
*/
|
|
21
|
-
readonly alias: string;
|
|
22
|
-
/** The adapter package a project installs, e.g. `@aventara/prisma7-adapter`. */
|
|
23
|
-
readonly adapterPackage: string;
|
|
24
|
-
readonly orm: {
|
|
25
|
-
/** `aventara.adapter.orm`, e.g. `prisma`: the family the wizard groups majors under. */
|
|
26
|
-
readonly family: string;
|
|
27
|
-
/** `aventara.adapter.ormLabel`, e.g. `Prisma`: how the wizard names the family. */
|
|
28
|
-
readonly label: string;
|
|
29
|
-
/** `aventara.adapter.ormPackage`, e.g. `@prisma/client`: whose installed version selects the entry. */
|
|
30
|
-
readonly package: string;
|
|
31
|
-
/** The one major `range` admits. */
|
|
32
|
-
readonly major: number;
|
|
33
|
-
};
|
|
34
|
-
/** `peerDependencies[orm.package]`: the ORM versions the adapter supports. */
|
|
35
|
-
readonly range: string;
|
|
36
|
-
/** Packages that identify the ORM family in a project. */
|
|
37
|
-
readonly familyPackages: readonly string[];
|
|
38
|
-
/** Database providers, in the adapter's order; the first is the default. */
|
|
39
|
-
readonly providers: readonly string[];
|
|
40
|
-
/** Provider → the driver adapter package for it. */
|
|
41
|
-
readonly drivers: Readonly<Record<string, string>>;
|
|
42
|
-
/** The ORM generators whose output the adapter reads. */
|
|
43
|
-
readonly generators: readonly string[];
|
|
44
|
-
/** The adapter's generate step: its one `bin`. */
|
|
45
|
-
readonly bin: string;
|
|
46
|
-
};
|
|
47
|
-
export type AdapterCatalog = readonly CatalogEntry[];
|
|
48
|
-
/** The generated catalog's literal type: what the template registry is checked against. */
|
|
49
|
-
export type Catalog = typeof ADAPTER_CATALOG;
|
|
50
|
-
export type EntryId = Catalog[number]["id"];
|
|
51
|
-
/** The providers one entry declares, as literals. */
|
|
52
|
-
export type ProviderOf<I extends EntryId> = Extract<Catalog[number], {
|
|
53
|
-
readonly id: I;
|
|
54
|
-
}>["providers"][number];
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { AdapterCatalog, CatalogEntry } from "./catalog-entry.interface.js";
|
|
2
|
-
/**
|
|
3
|
-
* 1. The ORM family: the catalog entries whose family packages the project depends
|
|
4
|
-
* on (a pattern ending in `*` is a prefix).
|
|
5
|
-
* 2. Every other family package installed must be of that same major — a Prisma 8
|
|
6
|
-
* CLI or an `@prisma/orm-*` beside a Prisma 7 client is a project
|
|
7
|
-
* mid-migration, refused.
|
|
8
|
-
* 3. The entry for that major, or a refusal naming what exists.
|
|
9
|
-
* 4. The installed version inside the entry's declared range.
|
|
10
|
-
* 5. Then what the project's ORM setup declares — provider, driver, generator —
|
|
11
|
-
* against the entry's providers, drivers and generators.
|
|
12
|
-
*
|
|
13
|
-
* Every refusal is one sentence naming what was found and what the catalog offers.
|
|
14
|
-
* Nothing has been written when one is raised.
|
|
15
|
-
*/
|
|
16
|
-
export type MatchVerdict = {
|
|
17
|
-
readonly kind: "matched";
|
|
18
|
-
readonly entry: CatalogEntry;
|
|
19
|
-
} | {
|
|
20
|
-
readonly kind: "refused";
|
|
21
|
-
readonly sentence: string;
|
|
22
|
-
};
|
|
23
|
-
export type InstalledOrm = {
|
|
24
|
-
/** The project's dependency names (dependencies and devDependencies). */
|
|
25
|
-
readonly dependencies: readonly string[];
|
|
26
|
-
/** The installed version of a package, or `undefined` when it is not installed. */
|
|
27
|
-
readonly installedVersion: (name: string) => string | undefined;
|
|
28
|
-
/** The command that installs the project's dependencies. */
|
|
29
|
-
readonly installCommand: string;
|
|
30
|
-
};
|
|
31
|
-
/** What the project's ORM setup states, read by the entry's templates. */
|
|
32
|
-
export type OrmSetup = {
|
|
33
|
-
readonly provider: string | undefined;
|
|
34
|
-
readonly generator: string | undefined;
|
|
35
|
-
/** The driver-adapter packages the project depends on. */
|
|
36
|
-
readonly drivers: readonly string[];
|
|
37
|
-
};
|
|
38
|
-
export declare function matchInstalledOrm(catalog: AdapterCatalog, project: InstalledOrm): MatchVerdict;
|
|
39
|
-
/** Step 5: the project's provider, driver and generator against what `entry` declares. */
|
|
40
|
-
export declare function matchOrmSetup(entry: CatalogEntry, setup: OrmSetup): string | undefined;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** `^7.10.0` → `7.10.0`; `>=7.10.0 <8` → `7.10.0`. */
|
|
2
|
-
export declare function lowestVersionOf(range: string): string;
|
|
3
|
-
/** `^12.0.1` → 12; `~6.0.2` → 6; a range with no number (`latest`, `*`) → `undefined`. */
|
|
4
|
-
export declare function lowestMajorOf(range: string): number | undefined;
|
|
5
|
-
/**
|
|
6
|
-
* Whether an installed `version` is in a declared `range`. Reads the comparator
|
|
7
|
-
* forms an adapter's peer range uses; a pre-release never satisfies (semver's rule
|
|
8
|
-
* for a range whose comparators carry none). Any other form is refused rather than
|
|
9
|
-
* guessed.
|
|
10
|
-
*/
|
|
11
|
-
export declare function satisfiesRange(version: string, range: string): boolean;
|
package/dist/cli.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { AdapterCatalog } from "./catalog/catalog-entry.interface.js";
|
|
2
|
-
import { type CommandRunner } from "./run/command.runner.js";
|
|
3
|
-
import { type Prompter } from "./wizard/answer.resolver.js";
|
|
4
|
-
/**
|
|
5
|
-
* `aventara` — the bin: `new` and `init`. A refusal is one sentence on stderr and
|
|
6
|
-
* exit 1, never a stack; anything else is a defect and keeps its stack.
|
|
7
|
-
*
|
|
8
|
-
* `init` initializes the project in the working directory
|
|
9
|
-
* (`run/init.orchestrator.ts`); `new` creates one with the pinned `nest new` and
|
|
10
|
-
* then runs the same pipeline over it (`run/new.orchestrator.ts`).
|
|
11
|
-
*/
|
|
12
|
-
export type CliIo = {
|
|
13
|
-
/** The working directory: where `init` initializes and `new` creates. */
|
|
14
|
-
readonly cwd: string;
|
|
15
|
-
readonly env: Readonly<Record<string, string | undefined>>;
|
|
16
|
-
readonly stdout: (text: string) => void;
|
|
17
|
-
readonly stderr: (text: string) => void;
|
|
18
|
-
readonly prompter: Prompter;
|
|
19
|
-
readonly runner?: CommandRunner;
|
|
20
|
-
readonly catalog?: AdapterCatalog;
|
|
21
|
-
};
|
|
22
|
-
export declare function runCli(argv: readonly string[], io: CliIo): Promise<number>;
|
|
23
|
-
/**
|
|
24
|
-
* Runs `aventara` over this process — its arguments, its terminal, its exit
|
|
25
|
-
* code. Called by the bin's entry (`aventara.bin.ts`) once the Node guard has
|
|
26
|
-
* admitted this Node; importing this module runs nothing, which lets `runCli`
|
|
27
|
-
* be tested in process.
|
|
28
|
-
*/
|
|
29
|
-
export declare function runFromProcess(): Promise<void>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { AdapterCatalog } from "../catalog/catalog-entry.interface.js";
|
|
2
|
-
import { type QuestionId } from "../wizard/wizard.questions.js";
|
|
3
|
-
/**
|
|
4
|
-
* The `aventara` command line: `new <name>` and `init`, each question's flag from
|
|
5
|
-
* the wizard's table, and the options that are not questions. Unknown, misplaced
|
|
6
|
-
* or repeated arguments are refused in one sentence; a flag's VALUE is the
|
|
7
|
-
* question's to judge, because what is valid (`--db`'s providers) depends on the
|
|
8
|
-
* catalog and on earlier answers.
|
|
9
|
-
*/
|
|
10
|
-
export type ScaffoldCommandName = "new" | "init";
|
|
11
|
-
export type ScaffoldCommand = {
|
|
12
|
-
readonly command: ScaffoldCommandName;
|
|
13
|
-
/** Raw answers by question, from flags and `new`'s positional `<name>`. */
|
|
14
|
-
readonly given: Readonly<Partial<Record<QuestionId, string>>>;
|
|
15
|
-
readonly skipInstall: boolean;
|
|
16
|
-
/** `new` only: passed through to `nest new`. */
|
|
17
|
-
readonly skipGit: boolean;
|
|
18
|
-
/** Accepts each unanswered question's default and confirms overwrites. */
|
|
19
|
-
readonly yes: boolean;
|
|
20
|
-
};
|
|
21
|
-
export type CliCommand =
|
|
22
|
-
/** `--help`; with `topic`, `aventara <topic> --help` (pilot.1). */
|
|
23
|
-
{
|
|
24
|
-
readonly command: "help";
|
|
25
|
-
readonly topic?: ScaffoldCommandName;
|
|
26
|
-
} | {
|
|
27
|
-
readonly command: "version";
|
|
28
|
-
} | ScaffoldCommand;
|
|
29
|
-
/** The command line cannot be understood. A refusal: one sentence, exit 1. */
|
|
30
|
-
export declare class CliCommandError extends Error {
|
|
31
|
-
readonly name = "CliCommandError";
|
|
32
|
-
}
|
|
33
|
-
/** `aventara <command> --help` (pilot.1): that command's usage alone. */
|
|
34
|
-
export declare function commandUsage(command: ScaffoldCommandName, catalog: AdapterCatalog): string;
|
|
35
|
-
/** `aventara --help`: both commands, each flag with the values `catalog` offers. */
|
|
36
|
-
export declare function usage(catalog: AdapterCatalog): string;
|
|
37
|
-
/** @throws CliCommandError when `argv` is not a command this CLI has. */
|
|
38
|
-
export declare function parseCliCommand(argv: readonly string[]): CliCommand;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** The sentence a bin answers on `version`, or `undefined` when `range` admits it. */
|
|
2
|
-
export declare function nodeVersionRefusal(bin: string, packageName: string, range: string, version: string): string | undefined;
|
|
3
|
-
/**
|
|
4
|
-
* Reads the manifest at `manifestUrl`; on a Node its `engines.node` does not
|
|
5
|
-
* admit, writes the sentence to stderr, sets exit code 1 and answers `true` —
|
|
6
|
-
* the bin then loads nothing else.
|
|
7
|
-
*/
|
|
8
|
-
export declare function refuseUnsupportedNode(bin: string, manifestUrl: URL): boolean;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { CatalogEntry } from "../catalog/catalog-entry.interface.js";
|
|
2
|
-
import { type ProjectInspection } from "../project/project.inspector.js";
|
|
3
|
-
import { type OrmScaffold } from "../templates/template.registry.js";
|
|
4
|
-
import type { PackageManager } from "../wizard/wizard.questions.js";
|
|
5
|
-
/**
|
|
6
|
-
* Pure apart from reading the files it would replace.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* The name of the script that regenerates the ORM client and the discovery
|
|
10
|
-
* artifact.
|
|
11
|
-
*/
|
|
12
|
-
export declare const PREPARE_SCRIPT = "aventara:prepare";
|
|
13
|
-
export type PlannedWrite = {
|
|
14
|
-
readonly path: string;
|
|
15
|
-
readonly content: string;
|
|
16
|
-
/** `create` a new file, or `replace` one whose content changes. */
|
|
17
|
-
readonly change: "create" | "replace";
|
|
18
|
-
};
|
|
19
|
-
export type ProjectPlan = {
|
|
20
|
-
/** What is written when the conflicts are kept as they are. */
|
|
21
|
-
readonly keeping: readonly PlannedWrite[];
|
|
22
|
-
/** What is written once the conflicts are confirmed (`--yes`, or a yes). */
|
|
23
|
-
readonly replacing: readonly PlannedWrite[];
|
|
24
|
-
/** Existing content that differs from what would be written. */
|
|
25
|
-
readonly conflicts: readonly string[];
|
|
26
|
-
readonly warnings: readonly string[];
|
|
27
|
-
/** Printed when the anchored edit could not be made. */
|
|
28
|
-
readonly instructions: string | undefined;
|
|
29
|
-
readonly nextSteps: readonly string[];
|
|
30
|
-
};
|
|
31
|
-
export type PlanInput = {
|
|
32
|
-
readonly inspection: ProjectInspection;
|
|
33
|
-
readonly entry: CatalogEntry;
|
|
34
|
-
readonly scaffold: OrmScaffold;
|
|
35
|
-
readonly packageManager: PackageManager;
|
|
36
|
-
/** This CLI's version: every Aventara package is pinned to it. */
|
|
37
|
-
readonly aventaraVersion: string;
|
|
38
|
-
readonly skipInstall: boolean;
|
|
39
|
-
/** The current text of a project file, or `undefined` when absent. */
|
|
40
|
-
readonly read: (file: string) => string | undefined;
|
|
41
|
-
/** The anchored edit is not attempted; the wiring is printed. */
|
|
42
|
-
readonly wiringByHand?: string;
|
|
43
|
-
/** Said before the write, beside the planner's own. */
|
|
44
|
-
readonly warnings?: readonly string[];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* pilot.1 — the frontend's first command, as the developer can run it: the
|
|
48
|
-
* package manager's own one-off runner (`npx` or `pnpm dlx`), and — while this
|
|
49
|
-
* CLI is a prerelease — its dist-tag, so the client comes from the same release
|
|
50
|
-
* (`0.1.0-pilot.1` → `@aventara/client@pilot`). A release has no tag to name.
|
|
51
|
-
*/
|
|
52
|
-
export declare function frontendInitCommand(packageManager: PackageManager, cliVersion: string): string;
|
|
53
|
-
export declare function planInit(input: PlanInput): ProjectPlan;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { PackageManifest } from "../apply/manifest.merger.js";
|
|
2
|
-
import type { AdapterCatalog, CatalogEntry } from "../catalog/catalog-entry.interface.js";
|
|
3
|
-
import type { ModuleKind } from "../templates/template.registry.js";
|
|
4
|
-
import type { PackageManager } from "../wizard/wizard.questions.js";
|
|
5
|
-
/** The project is not one `aventara init` serves. A refusal: one sentence, nothing written. */
|
|
6
|
-
export declare class ProjectRefusedError extends Error {
|
|
7
|
-
readonly name = "ProjectRefusedError";
|
|
8
|
-
}
|
|
9
|
-
/** The ORM a project already has, by the catalog's family packages. */
|
|
10
|
-
export type OrmPresence = {
|
|
11
|
-
readonly kind: "absent";
|
|
12
|
-
} | {
|
|
13
|
-
readonly kind: "present";
|
|
14
|
-
/** The family packages found among its dependencies. */
|
|
15
|
-
readonly packages: readonly string[];
|
|
16
|
-
/** The catalog entries whose family they belong to. */
|
|
17
|
-
readonly families: readonly CatalogEntry["orm"]["label"][];
|
|
18
|
-
};
|
|
19
|
-
export type ProjectInspection = {
|
|
20
|
-
readonly directory: string;
|
|
21
|
-
readonly manifest: PackageManifest;
|
|
22
|
-
readonly manifestText: string;
|
|
23
|
-
readonly moduleKind: ModuleKind;
|
|
24
|
-
/** The package manager the lockfile names, if exactly one does. */
|
|
25
|
-
readonly lockfile: PackageManager | undefined;
|
|
26
|
-
readonly orm: OrmPresence;
|
|
27
|
-
/** `@nestjs/config` loads `.env` itself, so the start scripts are left alone. */
|
|
28
|
-
readonly usesNestConfig: boolean;
|
|
29
|
-
};
|
|
30
|
-
/** The file the anchored edit opens. */
|
|
31
|
-
export declare const APP_MODULE = "src/app.module.ts";
|
|
32
|
-
export declare function inspectProject(directory: string, catalog: AdapterCatalog): ProjectInspection;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 1. **Candidates**: exported classes that `extends` the ORM's client class, where
|
|
3
|
-
* the file imports that class from a specifier the ORM's templates recognise
|
|
4
|
-
* (the generated client, or the ORM package).
|
|
5
|
-
* 3. **Modules**: each `@Module({…})`-decorated exported class with the
|
|
6
|
-
* identifiers its `providers` and `exports` list, and whether it is
|
|
7
|
-
* `@Global()`.
|
|
8
|
-
*
|
|
9
|
-
* Which of them is *the* service is the caller's question (the wizard's).
|
|
10
|
-
*/
|
|
11
|
-
export type ExportReference = {
|
|
12
|
-
/** Relative to the project root, POSIX separators. */
|
|
13
|
-
readonly file: string;
|
|
14
|
-
readonly exportName: string;
|
|
15
|
-
};
|
|
16
|
-
export type ServiceComposition = ExportReference & {
|
|
17
|
-
/** The member that holds the client. */
|
|
18
|
-
readonly member: string;
|
|
19
|
-
};
|
|
20
|
-
export type ModuleDeclaration = ExportReference & {
|
|
21
|
-
readonly providers: readonly string[];
|
|
22
|
-
readonly exports: readonly string[];
|
|
23
|
-
readonly global: boolean;
|
|
24
|
-
};
|
|
25
|
-
export type ServiceScan = {
|
|
26
|
-
readonly candidates: readonly ExportReference[];
|
|
27
|
-
readonly compositions: readonly ServiceComposition[];
|
|
28
|
-
readonly modules: readonly ModuleDeclaration[];
|
|
29
|
-
};
|
|
30
|
-
export type ClientShape = {
|
|
31
|
-
/** The client class a service extends, e.g. the ORM's generated client. */
|
|
32
|
-
readonly clientClass: string;
|
|
33
|
-
/** Whether `specifier`, imported by `file` (project-relative), is the client's module. */
|
|
34
|
-
readonly importsClient: (specifier: string, file: string) => boolean;
|
|
35
|
-
/** Directories under `src/` that hold generated code, skipped. */
|
|
36
|
-
readonly skip: readonly string[];
|
|
37
|
-
};
|
|
38
|
-
export declare function scanServices(directory: string, shape: ClientShape): ServiceScan;
|
|
39
|
-
/** The modules that make `service` injectable elsewhere: providing and exporting it, or global. */
|
|
40
|
-
export declare function modulesProviding(scan: ServiceScan, service: ExportReference): readonly ModuleDeclaration[];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A lexical view of TypeScript source — enough to find decorators, classes,
|
|
3
|
-
* imports and brackets **in code**, never inside a comment, a string or a
|
|
4
|
-
* template literal's text — with no compiler: `aventara new` runs before
|
|
5
|
-
* anything (TypeScript included) is installed in the project, and the CLI
|
|
6
|
-
* carries no TypeScript of its own. Shared by the anchored `app.module.ts` edit
|
|
7
|
-
* and the detection of a developer's ORM service.
|
|
8
|
-
*/
|
|
9
|
-
/** For each character: is it code (not inside a comment, string or template text)? */
|
|
10
|
-
export declare function codeMask(text: string): boolean[];
|
|
11
|
-
/** Every index where `token` starts in code. */
|
|
12
|
-
export declare function codeIndexes(text: string, code: boolean[], token: RegExp): number[];
|
|
13
|
-
export declare const OPENERS: Readonly<Record<string, string>>;
|
|
14
|
-
/** The index of the bracket closing the one at `open`, counting code brackets only. */
|
|
15
|
-
export declare function closing(text: string, code: boolean[], open: number): number;
|
|
16
|
-
export declare function nextCode(text: string, code: boolean[], from: number): number;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The one external process seam: a command, its arguments, a working directory.
|
|
3
|
-
* Its stdout is always **piped**, never inherited — `nest new` asks a question it
|
|
4
|
-
* has no flag for when its stdout is a terminal — and both streams are collected,
|
|
5
|
-
* so a failure can be reported with what it said.
|
|
6
|
-
*/
|
|
7
|
-
export type CommandResult = {
|
|
8
|
-
readonly code: number;
|
|
9
|
-
readonly stdout: string;
|
|
10
|
-
readonly stderr: string;
|
|
11
|
-
};
|
|
12
|
-
export type CommandRunner = (command: string, args: readonly string[], options: {
|
|
13
|
-
readonly cwd: string;
|
|
14
|
-
}) => Promise<CommandResult>;
|
|
15
|
-
export declare const runCommand: CommandRunner;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { AdapterCatalog } from "../catalog/catalog-entry.interface.js";
|
|
2
|
-
import type { ScaffoldCommand } from "../command/command.parser.js";
|
|
3
|
-
import { type Prompter } from "../wizard/answer.resolver.js";
|
|
4
|
-
import type { CommandRunner } from "./command.runner.js";
|
|
5
|
-
/**
|
|
6
|
-
* Every step before the write reads; so a refusal anywhere before it leaves the
|
|
7
|
-
* project exactly as it was. A failure after it (the install) names the command,
|
|
8
|
-
* its exit code and what to re-run; nothing is rolled back.
|
|
9
|
-
*/
|
|
10
|
-
export type InitIo = {
|
|
11
|
-
readonly directory: string;
|
|
12
|
-
readonly env: Readonly<Record<string, string | undefined>>;
|
|
13
|
-
readonly stdout: (text: string) => void;
|
|
14
|
-
readonly stderr: (text: string) => void;
|
|
15
|
-
readonly prompter: Prompter;
|
|
16
|
-
readonly runner: CommandRunner;
|
|
17
|
-
readonly catalog: AdapterCatalog;
|
|
18
|
-
/** This CLI's own version. */
|
|
19
|
-
readonly aventaraVersion: string;
|
|
20
|
-
/** Next steps that come before init's own (`new`'s `cd <name>`). */
|
|
21
|
-
readonly firstSteps?: readonly string[];
|
|
22
|
-
};
|
|
23
|
-
/** The install step failed after the files were written. Reported, exit 1. */
|
|
24
|
-
export declare class InstallFailedError extends Error {
|
|
25
|
-
readonly name = "InstallFailedError";
|
|
26
|
-
}
|
|
27
|
-
export declare function runInit(command: ScaffoldCommand, io: InitIo): Promise<number>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ScaffoldCommand } from "../command/command.parser.js";
|
|
2
|
-
import { type InitIo } from "./init.orchestrator.js";
|
|
3
|
-
/**
|
|
4
|
-
* `aventara new <name>`: the pinned `nest new`, then **exactly** `aventara init`'s
|
|
5
|
-
* pipeline over the fresh project, with the wizard's answers carried in — so every
|
|
6
|
-
* `new` run exercises the anchored edit, the merges and the templates `init` uses
|
|
7
|
-
* — and, after the install, the project's first commit (`scaffold.committer.ts`,
|
|
8
|
-
* pilot.3).
|
|
9
|
-
*
|
|
10
|
-
* Nest authors its own scaffold: the CLI never writes Nest's files. Its output is
|
|
11
|
-
* pinned by digest, so a `@nestjs/cli` that writes something else stops the run
|
|
12
|
-
* before anything of Aventara's is written over it.
|
|
13
|
-
*/
|
|
14
|
-
export declare const NEST_CLI = "@nestjs/cli@12.0.8";
|
|
15
|
-
export declare const NEST_APP_MODULE_SHA256 = "fe98c4cd2552342272494652287c02e4ef58db3072fcb18513ea831c60f85778";
|
|
16
|
-
export type NewIo = Omit<InitIo, "directory"> & {
|
|
17
|
-
/** Where `new` creates the project directory. */
|
|
18
|
-
readonly cwd: string;
|
|
19
|
-
};
|
|
20
|
-
export declare function runNew(command: ScaffoldCommand, io: NewIo): Promise<number>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { CommandRunner } from "./command.runner.js";
|
|
2
|
-
/**
|
|
3
|
-
* pilot.3 — `aventara new` ends with one commit of the whole scaffold, the
|
|
4
|
-
* install's lockfile included, under one fixed message. `.env` is not in it: the
|
|
5
|
-
* scaffold's `.gitignore` lists it (Nest's own does too). `init` never commits:
|
|
6
|
-
* the project is the developer's.
|
|
7
|
-
*
|
|
8
|
-
* Never a failure: where a commit cannot or should not be made, one line says why
|
|
9
|
-
* and the run still succeeds —
|
|
10
|
-
* - git is not installed;
|
|
11
|
-
* - the directory `new` ran in is inside a git work tree already (a monorepo): the
|
|
12
|
-
* project belongs to that repository, and gets no commit of its own;
|
|
13
|
-
* - git has no `user.name` and `user.email` to commit as. `--skip-git` (passed to
|
|
14
|
-
* `nest new`, which then initializes no repository) makes no commit and says
|
|
15
|
-
* nothing.
|
|
16
|
-
*
|
|
17
|
-
* git runs through the one process seam, `CommandRunner`.
|
|
18
|
-
*/
|
|
19
|
-
export declare const INITIAL_COMMIT_MESSAGE = "Initial Aventara Scaffold";
|
|
20
|
-
/** Where `new` runs, as git sees it — read BEFORE `nest new` initializes a repository. */
|
|
21
|
-
export type GitSurroundings = "no-git" | "inside-work-tree" | "outside";
|
|
22
|
-
/** Whether git is installed, and whether `directory` lies in a work tree. */
|
|
23
|
-
export declare function gitSurroundings(runner: CommandRunner, directory: string): Promise<GitSurroundings>;
|
|
24
|
-
/**
|
|
25
|
-
* Commits the project in `directory` as its first commit, or says why not: the
|
|
26
|
-
* line to print, without the `aventara: ` prefix or the final period.
|
|
27
|
-
*/
|
|
28
|
-
export declare function commitScaffold(runner: CommandRunner, directory: string, surroundings: GitSurroundings, enclosing: string): Promise<string>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where the public documentation lives: the one base every link the scaffold
|
|
3
|
-
* writes into a project starts from. A placeholder until the docs domain is
|
|
4
|
-
* settled; changing it changes only comments in the files the CLI writes.
|
|
5
|
-
*/
|
|
6
|
-
export declare const DOCS_BASE_URL = "https://<docs-domain>";
|
|
7
|
-
/** The documentation's rate-limiting section, linked from the scaffold's `main.ts`. */
|
|
8
|
-
export declare const RATE_LIMITING_DOCS = "https://<docs-domain>/docs/limits-and-safety#rate-limiting";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { PackageManifest } from "../../apply/manifest.merger.js";
|
|
2
|
-
import type { ClientShape, ExportReference } from "../../project/service.detector.js";
|
|
3
|
-
import { type OrmProjectFacts, type OrmScaffold, type ReuseInput, type ScaffoldInput } from "../template.registry.js";
|
|
4
|
-
declare function scaffold(input: ScaffoldInput): OrmScaffold;
|
|
5
|
-
declare function reuse(input: ReuseInput): OrmScaffold;
|
|
6
|
-
declare function readProject(directory: string, manifest: PackageManifest): OrmProjectFacts;
|
|
7
|
-
declare function clientShape(facts: OrmProjectFacts): ClientShape;
|
|
8
|
-
export declare const PRISMA7_TEMPLATES: {
|
|
9
|
-
readonly providers: {
|
|
10
|
-
readonly sqlite: {
|
|
11
|
-
readonly driverClass: "PrismaBetterSqlite3";
|
|
12
|
-
readonly driverOptions: "{ url }";
|
|
13
|
-
readonly databaseUrl: "file:./dev.db";
|
|
14
|
-
readonly gitignore: readonly ["/dev.db*"];
|
|
15
|
-
readonly nativeBuilds: readonly ["@prisma/engines", "better-sqlite3", "prisma"];
|
|
16
|
-
};
|
|
17
|
-
readonly postgresql: {
|
|
18
|
-
readonly driverClass: "PrismaPg";
|
|
19
|
-
readonly driverOptions: "{ connectionString: url }";
|
|
20
|
-
readonly databaseUrl: "postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public";
|
|
21
|
-
readonly gitignore: readonly [];
|
|
22
|
-
readonly nativeBuilds: readonly ["@prisma/engines", "prisma"];
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
readonly scaffold: typeof scaffold;
|
|
26
|
-
readonly readProject: typeof readProject;
|
|
27
|
-
readonly clientShape: typeof clientShape;
|
|
28
|
-
readonly newService: {
|
|
29
|
-
readonly service: ExportReference;
|
|
30
|
-
readonly module: ExportReference;
|
|
31
|
-
};
|
|
32
|
-
readonly reuse: typeof reuse;
|
|
33
|
-
};
|
|
34
|
-
export {};
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import type { PackageManifest } from "../apply/manifest.merger.js";
|
|
2
|
-
import type { CatalogEntry, EntryId, ProviderOf } from "../catalog/catalog-entry.interface.js";
|
|
3
|
-
import type { ClientShape, ExportReference } from "../project/service.detector.js";
|
|
4
|
-
import type { PackageManager } from "../wizard/wizard.questions.js";
|
|
5
|
-
/**
|
|
6
|
-
* The registry is **total** in both directions, and both are checked before a
|
|
7
|
-
* project is ever scaffolded:
|
|
8
|
-
* - at compile time, over the generated catalog's literal type: an entry with no
|
|
9
|
-
* template set, or a template set missing a provider its adapter declares, does
|
|
10
|
-
* not type-check;
|
|
11
|
-
* - at build time, by the catalog generator: a templates directory with no
|
|
12
|
-
* adapter, or an adapter with no templates directory, fails the build.
|
|
13
|
-
*/
|
|
14
|
-
/** What changes with the database provider an entry offers. */
|
|
15
|
-
export type ProviderTemplate = {
|
|
16
|
-
/** The driver adapter's class, constructed in the written ORM service. */
|
|
17
|
-
readonly driverClass: string;
|
|
18
|
-
/** The driver class's constructor argument, given the connection string as `url`. */
|
|
19
|
-
readonly driverOptions: string;
|
|
20
|
-
/** The `DATABASE_URL` line's value; a placeholder where it cannot be known. */
|
|
21
|
-
readonly databaseUrl: string;
|
|
22
|
-
/** `.gitignore` lines this provider's files need (a SQLite database file). */
|
|
23
|
-
readonly gitignore: readonly string[];
|
|
24
|
-
/** Packages whose install scripts pnpm must be allowed to run. */
|
|
25
|
-
readonly nativeBuilds: readonly string[];
|
|
26
|
-
};
|
|
27
|
-
export type ModuleKind = "esm" | "cjs";
|
|
28
|
-
/**
|
|
29
|
-
* The entrypoint every scaffold mounts the protocol at: written into
|
|
30
|
-
* `src/aventara.config.ts`, and tested by the e2e spec (pilot.1).
|
|
31
|
-
*/
|
|
32
|
-
export declare const SCAFFOLD_ENTRYPOINT = "/api";
|
|
33
|
-
/** What a template set is asked to scaffold. */
|
|
34
|
-
export type ScaffoldInput = {
|
|
35
|
-
readonly entry: CatalogEntry;
|
|
36
|
-
/** One of `entry.providers`. */
|
|
37
|
-
readonly provider: string;
|
|
38
|
-
readonly moduleKind: ModuleKind;
|
|
39
|
-
readonly packageManager: PackageManager;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* What an ORM's templates contribute to a project. Everything here is the
|
|
43
|
-
* ORM's; what is Nest's (the start scripts, the anchored `app.module.ts` edit,
|
|
44
|
-
* `AventaraModule`'s import) and what is Aventara's (its packages, the
|
|
45
|
-
* `aventara:prepare` and `postinstall` script names) is the planner's.
|
|
46
|
-
*/
|
|
47
|
-
export type OrmScaffold = {
|
|
48
|
-
/** New, developer-owned files. */
|
|
49
|
-
readonly files: readonly {
|
|
50
|
-
readonly path: string;
|
|
51
|
-
readonly content: string;
|
|
52
|
-
}[];
|
|
53
|
-
/** `.env` entries. */
|
|
54
|
-
readonly env: Readonly<Record<string, string>>;
|
|
55
|
-
readonly gitignore: readonly string[];
|
|
56
|
-
readonly dependencies: Readonly<Record<string, string>>;
|
|
57
|
-
readonly devDependencies: Readonly<Record<string, string>>;
|
|
58
|
-
/** The command `aventara:prepare` runs. */
|
|
59
|
-
readonly prepare: string;
|
|
60
|
-
/** What the anchored `app.module.ts` edit adds: import lines, and `imports:` entries. */
|
|
61
|
-
readonly appModule: {
|
|
62
|
-
readonly imports: readonly string[];
|
|
63
|
-
readonly entries: readonly string[];
|
|
64
|
-
};
|
|
65
|
-
readonly nativeBuilds: readonly string[];
|
|
66
|
-
/** The ORM's next steps, after the install and before the server starts. */
|
|
67
|
-
readonly nextSteps: readonly string[];
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* What a project's existing ORM setup states, read by the entry's templates — the
|
|
71
|
-
* ORM's own file layout is template knowledge; judging it against the catalog is
|
|
72
|
-
* the matcher's (`catalog.matcher.ts`).
|
|
73
|
-
*/
|
|
74
|
-
export type OrmProjectFacts = {
|
|
75
|
-
/** The schema the generate step reads, relative to the project root. */
|
|
76
|
-
readonly schema: string;
|
|
77
|
-
readonly provider: string | undefined;
|
|
78
|
-
readonly generator: string | undefined;
|
|
79
|
-
/** The generated client's directory, relative to the project root. */
|
|
80
|
-
readonly clientOutput: string | undefined;
|
|
81
|
-
/** The driver-adapter packages the project depends on. */
|
|
82
|
-
readonly drivers: readonly string[];
|
|
83
|
-
};
|
|
84
|
-
/** Reusing a project's ORM setup: its schema, its output, its service. */
|
|
85
|
-
export type ReuseInput = {
|
|
86
|
-
readonly entry: CatalogEntry;
|
|
87
|
-
readonly facts: OrmProjectFacts & {
|
|
88
|
-
readonly provider: string;
|
|
89
|
-
readonly clientOutput: string;
|
|
90
|
-
};
|
|
91
|
-
readonly moduleKind: ModuleKind;
|
|
92
|
-
readonly packageManager: PackageManager;
|
|
93
|
-
/** The developer's service, or the template's new one when it is to be written. */
|
|
94
|
-
readonly service: ExportReference & {
|
|
95
|
-
readonly clientMember?: string;
|
|
96
|
-
};
|
|
97
|
-
readonly module: ExportReference;
|
|
98
|
-
/** Whether `service` and `module` are the template's new file, to be written. */
|
|
99
|
-
readonly writeService: boolean;
|
|
100
|
-
/** Where the discovery artifact goes, relative to the project root. */
|
|
101
|
-
readonly artifact: string;
|
|
102
|
-
};
|
|
103
|
-
export type TemplateSet<I extends EntryId> = {
|
|
104
|
-
readonly providers: {
|
|
105
|
-
readonly [P in ProviderOf<I>]: ProviderTemplate;
|
|
106
|
-
};
|
|
107
|
-
readonly scaffold: (input: ScaffoldInput) => OrmScaffold;
|
|
108
|
-
/** Reads an existing setup's facts; `undefined` when there is none to read. */
|
|
109
|
-
readonly readProject: (directory: string, manifest: PackageManifest) => OrmProjectFacts;
|
|
110
|
-
/** How the developer's service is recognised in their source. */
|
|
111
|
-
readonly clientShape: (facts: OrmProjectFacts) => ClientShape;
|
|
112
|
-
/** The service init writes when the project has none: its file and names. */
|
|
113
|
-
readonly newService: {
|
|
114
|
-
readonly service: ExportReference;
|
|
115
|
-
readonly module: ExportReference;
|
|
116
|
-
};
|
|
117
|
-
/** A project with the ORM already set up: no ORM file written or edited. */
|
|
118
|
-
readonly reuse: (input: ReuseInput) => OrmScaffold;
|
|
119
|
-
};
|
|
120
|
-
export type TemplateRegistry = {
|
|
121
|
-
readonly [I in EntryId]: TemplateSet<I>;
|
|
122
|
-
};
|
|
123
|
-
export declare const TEMPLATE_REGISTRY: {
|
|
124
|
-
readonly prisma7: {
|
|
125
|
-
readonly providers: {
|
|
126
|
-
readonly sqlite: {
|
|
127
|
-
readonly driverClass: "PrismaBetterSqlite3";
|
|
128
|
-
readonly driverOptions: "{ url }";
|
|
129
|
-
readonly databaseUrl: "file:./dev.db";
|
|
130
|
-
readonly gitignore: readonly ["/dev.db*"];
|
|
131
|
-
readonly nativeBuilds: readonly ["@prisma/engines", "better-sqlite3", "prisma"];
|
|
132
|
-
};
|
|
133
|
-
readonly postgresql: {
|
|
134
|
-
readonly driverClass: "PrismaPg";
|
|
135
|
-
readonly driverOptions: "{ connectionString: url }";
|
|
136
|
-
readonly databaseUrl: "postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public";
|
|
137
|
-
readonly gitignore: readonly [];
|
|
138
|
-
readonly nativeBuilds: readonly ["@prisma/engines", "prisma"];
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
readonly scaffold: (input: ScaffoldInput) => OrmScaffold;
|
|
142
|
-
readonly readProject: (directory: string, manifest: PackageManifest) => OrmProjectFacts;
|
|
143
|
-
readonly clientShape: (facts: OrmProjectFacts) => ClientShape;
|
|
144
|
-
readonly newService: {
|
|
145
|
-
readonly service: ExportReference;
|
|
146
|
-
readonly module: ExportReference;
|
|
147
|
-
};
|
|
148
|
-
readonly reuse: (input: ReuseInput) => OrmScaffold;
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
/** The template set for `entry` — every catalog entry has one (checked at build). */
|
|
152
|
-
export declare function templatesFor(entry: CatalogEntry): TemplateSet<EntryId>;
|