@zukhruf/nx 0.8.29 → 0.8.31
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/README.md +825 -9
- package/dist/generators/add-keys.d.ts +7 -0
- package/dist/generators/add-keys.d.ts.map +1 -0
- package/dist/generators/add-keys.js +14 -0
- package/dist/generators/add-keys.js.map +1 -0
- package/dist/generators/add-lines.d.ts +8 -0
- package/dist/generators/add-lines.d.ts.map +1 -0
- package/dist/generators/add-lines.js +21 -0
- package/dist/generators/add-lines.js.map +1 -0
- package/dist/generators/app-directory.d.ts +17 -0
- package/dist/generators/app-directory.d.ts.map +1 -0
- package/dist/generators/app-directory.js +34 -0
- package/dist/generators/app-directory.js.map +1 -0
- package/dist/generators/dokploy/files.d.ts +21 -0
- package/dist/generators/dokploy/files.d.ts.map +1 -0
- package/dist/generators/dokploy/files.js +755 -0
- package/dist/generators/dokploy/files.js.map +1 -0
- package/dist/generators/dokploy/generator.d.ts +75 -0
- package/dist/generators/dokploy/generator.d.ts.map +1 -0
- package/dist/generators/dokploy/generator.js +139 -0
- package/dist/generators/dokploy/generator.js.map +1 -0
- package/dist/generators/dokploy/providers.d.ts +15 -0
- package/dist/generators/dokploy/providers.d.ts.map +1 -0
- package/dist/generators/dokploy/providers.js +114 -0
- package/dist/generators/dokploy/providers.js.map +1 -0
- package/dist/generators/init/files.d.ts +81 -0
- package/dist/generators/init/files.d.ts.map +1 -0
- package/dist/generators/init/files.js +278 -0
- package/dist/generators/init/files.js.map +1 -0
- package/dist/generators/init/generator.d.ts +8 -0
- package/dist/generators/init/generator.d.ts.map +1 -0
- package/dist/generators/init/generator.js +72 -0
- package/dist/generators/init/generator.js.map +1 -0
- package/dist/generators/init/nx-json.d.ts +20 -0
- package/dist/generators/init/nx-json.d.ts.map +1 -0
- package/dist/generators/init/nx-json.js +126 -0
- package/dist/generators/init/nx-json.js.map +1 -0
- package/dist/generators/init/root-package-json.d.ts +25 -0
- package/dist/generators/init/root-package-json.d.ts.map +1 -0
- package/dist/generators/init/root-package-json.js +49 -0
- package/dist/generators/init/root-package-json.js.map +1 -0
- package/dist/generators/node-app/files.d.ts +43 -0
- package/dist/generators/node-app/files.d.ts.map +1 -0
- package/dist/generators/node-app/files.js +522 -0
- package/dist/generators/node-app/files.js.map +1 -0
- package/dist/generators/node-app/generator.d.ts +17 -0
- package/dist/generators/node-app/generator.d.ts.map +1 -0
- package/dist/generators/node-app/generator.js +319 -0
- package/dist/generators/node-app/generator.js.map +1 -0
- package/dist/generators/nx-plugin.d.ts +16 -0
- package/dist/generators/nx-plugin.d.ts.map +1 -0
- package/dist/generators/nx-plugin.js +27 -0
- package/dist/generators/nx-plugin.js.map +1 -0
- package/dist/generators/pair/files.d.ts +4 -0
- package/dist/generators/pair/files.d.ts.map +1 -0
- package/dist/generators/pair/files.js +73 -0
- package/dist/generators/pair/files.js.map +1 -0
- package/dist/generators/pair/generator.d.ts +19 -0
- package/dist/generators/pair/generator.d.ts.map +1 -0
- package/dist/generators/pair/generator.js +70 -0
- package/dist/generators/pair/generator.js.map +1 -0
- package/dist/generators/preset/generator.d.ts +14 -0
- package/dist/generators/preset/generator.d.ts.map +1 -0
- package/dist/generators/preset/generator.js +43 -0
- package/dist/generators/preset/generator.js.map +1 -0
- package/dist/generators/prisma/files.d.ts +20 -0
- package/dist/generators/prisma/files.d.ts.map +1 -0
- package/dist/generators/prisma/files.js +183 -0
- package/dist/generators/prisma/files.js.map +1 -0
- package/dist/generators/prisma/generator.d.ts +17 -0
- package/dist/generators/prisma/generator.d.ts.map +1 -0
- package/dist/generators/prisma/generator.js +258 -0
- package/dist/generators/prisma/generator.js.map +1 -0
- package/dist/generators/react-app/files.d.ts +7 -0
- package/dist/generators/react-app/files.d.ts.map +1 -0
- package/dist/generators/react-app/files.js +188 -0
- package/dist/generators/react-app/files.js.map +1 -0
- package/dist/generators/react-app/generator.d.ts +12 -0
- package/dist/generators/react-app/generator.d.ts.map +1 -0
- package/dist/generators/react-app/generator.js +242 -0
- package/dist/generators/react-app/generator.js.map +1 -0
- package/dist/generators/react.d.ts +29 -0
- package/dist/generators/react.d.ts.map +1 -0
- package/dist/generators/react.js +64 -0
- package/dist/generators/react.js.map +1 -0
- package/dist/generators/root-dependencies.d.ts +21 -0
- package/dist/generators/root-dependencies.d.ts.map +1 -0
- package/dist/generators/root-dependencies.js +56 -0
- package/dist/generators/root-dependencies.js.map +1 -0
- package/dist/generators/ui-package/files.d.ts +37 -0
- package/dist/generators/ui-package/files.d.ts.map +1 -0
- package/dist/generators/ui-package/files.js +118 -0
- package/dist/generators/ui-package/files.js.map +1 -0
- package/dist/generators/ui-package/generator.d.ts +14 -0
- package/dist/generators/ui-package/generator.d.ts.map +1 -0
- package/dist/generators/ui-package/generator.js +111 -0
- package/dist/generators/ui-package/generator.js.map +1 -0
- package/dist/generators/versions.d.ts +72 -0
- package/dist/generators/versions.d.ts.map +1 -0
- package/dist/generators/versions.js +110 -0
- package/dist/generators/versions.js.map +1 -0
- package/dist/generators/workspace-scope.d.ts +8 -0
- package/dist/generators/workspace-scope.d.ts.map +1 -0
- package/dist/generators/workspace-scope.js +15 -0
- package/dist/generators/workspace-scope.js.map +1 -0
- package/dist/opentofu/check-plan-fresh.d.ts +2 -0
- package/dist/opentofu/check-plan-fresh.d.ts.map +1 -0
- package/dist/opentofu/check-plan-fresh.js +47 -0
- package/dist/opentofu/check-plan-fresh.js.map +1 -0
- package/dist/opentofu/plugin.d.ts +9 -0
- package/dist/opentofu/plugin.d.ts.map +1 -0
- package/dist/opentofu/plugin.js +108 -0
- package/dist/opentofu/plugin.js.map +1 -0
- package/dist/prisma/plugin.d.ts +9 -0
- package/dist/prisma/plugin.d.ts.map +1 -0
- package/dist/prisma/plugin.js +83 -0
- package/dist/prisma/plugin.js.map +1 -0
- package/dist/project-roots.d.ts +5 -0
- package/dist/project-roots.d.ts.map +1 -1
- package/dist/project-roots.js +10 -0
- package/dist/project-roots.js.map +1 -1
- package/dist/test/plugin.js +1 -7
- package/dist/test/plugin.js.map +1 -1
- package/generators.json +44 -0
- package/package.json +44 -5
- package/src/generators/dokploy/schema.json +48 -0
- package/src/generators/init/schema.json +8 -0
- package/src/generators/node-app/schema.json +22 -0
- package/src/generators/pair/schema.json +18 -0
- package/src/generators/preset/schema.json +18 -0
- package/src/generators/prisma/schema.json +21 -0
- package/src/generators/react-app/schema.json +17 -0
- package/src/generators/ui-package/schema.json +22 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const schemaPrisma = "// The models go in models/*.prisma. The generate target writes the client into\n// src/prisma, which is not committed.\ngenerator client {\n provider = \"prisma-client\"\n output = \"src/prisma\"\n importFileExtension = \"ts\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n";
|
|
2
|
+
export declare const prismaConfigTs = "import { defineConfig, env } from 'prisma/config';\n\n// Nx loads the .env of this project into each task, and the migration image\n// gets CONNECTION_STRING from its environment. A URL is read only when it is\n// set, so `prisma generate` runs with none.\nexport default defineConfig({\n schema: '.',\n migrations: { path: 'migrations' },\n datasource: {\n url: process.env.CONNECTION_STRING ? env('CONNECTION_STRING') : undefined,\n shadowDatabaseUrl: process.env.SHADOW_CONNECTION_STRING\n ? env('SHADOW_CONNECTION_STRING')\n : undefined,\n },\n});\n";
|
|
3
|
+
export declare const migrationLockToml = "# Please do not edit this file manually\n# It should be added in your version-control system (i.e. Git)\nprovider = \"postgresql\"\n";
|
|
4
|
+
export declare const indexTs = "import { PrismaPg } from '@prisma/adapter-pg';\n\nimport { PrismaClient } from './prisma/client.ts';\n\n/**\n * A client on the Postgres adapter. It reads no environment and opens no pool\n * at import, so each caller passes its own connection string: the backend its\n * CONNECTION_STRING, and a test the database of @zukhruf/testing/postgres.\n */\nexport function createPrisma(options: {\n connectionString: string;\n}): PrismaClient {\n return new PrismaClient({ adapter: new PrismaPg(options) });\n}\n\nexport * from './prisma/client.ts';\n";
|
|
5
|
+
export declare const testingTs = "import { readFile, readdir } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\n\nimport pg from 'pg';\n\n// src/ (development) and dist/ (default) each sit one level below the package\n// root that holds migrations/.\nconst migrationsDir = resolve(import.meta.dirname, '..', 'migrations');\n\n/**\n * Builds the schema of the committed migrations in an empty database: it runs\n * each migrations/<name>/migration.sql in order. It keeps no\n * _prisma_migrations record, because a test database is thrown away and never\n * migrated again. The deploy target applies migrations everywhere else.\n */\nexport async function applySchema(connectionString: string): Promise<void> {\n const migrations = (await readdir(migrationsDir, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .toSorted();\n const client = new pg.Client({ connectionString });\n await client.connect();\n try {\n for (const migration of migrations) {\n await client.query(\n await readFile(join(migrationsDir, migration, 'migration.sql'), 'utf8'),\n );\n }\n } finally {\n await client.end();\n }\n}\n";
|
|
6
|
+
/** The test of the db package, or of a backend that imports it. */
|
|
7
|
+
export declare function databaseTestTs(imports: {
|
|
8
|
+
client: string;
|
|
9
|
+
testing: string;
|
|
10
|
+
}): string;
|
|
11
|
+
export declare function eslintConfig(projectRoot: string, rootOffset: string): string;
|
|
12
|
+
export declare const envExample = "# Copy to `.env` (gitignored). Nx loads it into each task of this project, so\n# `nx run <project>:migrate` and `deploy` need no dotenv.\nCONNECTION_STRING=\n# Optional: the shadow database of `prisma migrate dev`.\nSHADOW_CONNECTION_STRING=\n";
|
|
13
|
+
export interface MigrationDockerfileOptions {
|
|
14
|
+
projectRoot: string;
|
|
15
|
+
packageName: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function migrationDockerfile(options: MigrationDockerfileOptions): string;
|
|
18
|
+
/** The lines that a backend's startup.ts gets: the client, connected before the app serves. */
|
|
19
|
+
export declare function startupClientTs(packageName: string): string;
|
|
20
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/prisma/files.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,2TAWxB,CAAC;AAEF,eAAO,MAAM,cAAc,kkBAe1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,yIAG7B,CAAC;AAEF,eAAO,MAAM,OAAO,wiBAgBnB,CAAC;AAEF,eAAO,MAAM,SAAS,iqCAgCrB,CAAC;AAEF,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,OAAO,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,MAAM,CAsBT;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAyB5E;AAED,eAAO,MAAM,UAAU,wPAKtB,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,0BAA0B,GAClC,MAAM,CA4BR;AAED,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAW3D"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// The content of each file that prisma writes. Each is a string in a .ts
|
|
2
|
+
// module, so tsc puts it in dist with no copy step (ADR 0009).
|
|
3
|
+
export const schemaPrisma = `// The models go in models/*.prisma. The generate target writes the client into
|
|
4
|
+
// src/prisma, which is not committed.
|
|
5
|
+
generator client {
|
|
6
|
+
provider = "prisma-client"
|
|
7
|
+
output = "src/prisma"
|
|
8
|
+
importFileExtension = "ts"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
datasource db {
|
|
12
|
+
provider = "postgresql"
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
export const prismaConfigTs = `import { defineConfig, env } from 'prisma/config';
|
|
16
|
+
|
|
17
|
+
// Nx loads the .env of this project into each task, and the migration image
|
|
18
|
+
// gets CONNECTION_STRING from its environment. A URL is read only when it is
|
|
19
|
+
// set, so \`prisma generate\` runs with none.
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
schema: '.',
|
|
22
|
+
migrations: { path: 'migrations' },
|
|
23
|
+
datasource: {
|
|
24
|
+
url: process.env.CONNECTION_STRING ? env('CONNECTION_STRING') : undefined,
|
|
25
|
+
shadowDatabaseUrl: process.env.SHADOW_CONNECTION_STRING
|
|
26
|
+
? env('SHADOW_CONNECTION_STRING')
|
|
27
|
+
: undefined,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
`;
|
|
31
|
+
export const migrationLockToml = `# Please do not edit this file manually
|
|
32
|
+
# It should be added in your version-control system (i.e. Git)
|
|
33
|
+
provider = "postgresql"
|
|
34
|
+
`;
|
|
35
|
+
export const indexTs = `import { PrismaPg } from '@prisma/adapter-pg';
|
|
36
|
+
|
|
37
|
+
import { PrismaClient } from './prisma/client.ts';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A client on the Postgres adapter. It reads no environment and opens no pool
|
|
41
|
+
* at import, so each caller passes its own connection string: the backend its
|
|
42
|
+
* CONNECTION_STRING, and a test the database of @zukhruf/testing/postgres.
|
|
43
|
+
*/
|
|
44
|
+
export function createPrisma(options: {
|
|
45
|
+
connectionString: string;
|
|
46
|
+
}): PrismaClient {
|
|
47
|
+
return new PrismaClient({ adapter: new PrismaPg(options) });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export * from './prisma/client.ts';
|
|
51
|
+
`;
|
|
52
|
+
export const testingTs = `import { readFile, readdir } from 'node:fs/promises';
|
|
53
|
+
import { join, resolve } from 'node:path';
|
|
54
|
+
|
|
55
|
+
import pg from 'pg';
|
|
56
|
+
|
|
57
|
+
// src/ (development) and dist/ (default) each sit one level below the package
|
|
58
|
+
// root that holds migrations/.
|
|
59
|
+
const migrationsDir = resolve(import.meta.dirname, '..', 'migrations');
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Builds the schema of the committed migrations in an empty database: it runs
|
|
63
|
+
* each migrations/<name>/migration.sql in order. It keeps no
|
|
64
|
+
* _prisma_migrations record, because a test database is thrown away and never
|
|
65
|
+
* migrated again. The deploy target applies migrations everywhere else.
|
|
66
|
+
*/
|
|
67
|
+
export async function applySchema(connectionString: string): Promise<void> {
|
|
68
|
+
const migrations = (await readdir(migrationsDir, { withFileTypes: true }))
|
|
69
|
+
.filter((entry) => entry.isDirectory())
|
|
70
|
+
.map((entry) => entry.name)
|
|
71
|
+
.toSorted();
|
|
72
|
+
const client = new pg.Client({ connectionString });
|
|
73
|
+
await client.connect();
|
|
74
|
+
try {
|
|
75
|
+
for (const migration of migrations) {
|
|
76
|
+
await client.query(
|
|
77
|
+
await readFile(join(migrationsDir, migration, 'migration.sql'), 'utf8'),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
} finally {
|
|
81
|
+
await client.end();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
/** The test of the db package, or of a backend that imports it. */
|
|
86
|
+
export function databaseTestTs(imports) {
|
|
87
|
+
return `import assert from 'node:assert/strict';
|
|
88
|
+
import { test } from 'node:test';
|
|
89
|
+
|
|
90
|
+
import { Postgres } from '@zukhruf/testing/postgres';
|
|
91
|
+
|
|
92
|
+
import { createPrisma } from '${imports.client}';
|
|
93
|
+
import { applySchema } from '${imports.testing}';
|
|
94
|
+
|
|
95
|
+
const postgres = new Postgres({ environment: process.env });
|
|
96
|
+
|
|
97
|
+
test('the client answers a query on a database with the schema of the migrations', async () => {
|
|
98
|
+
await using database = await postgres.database();
|
|
99
|
+
await applySchema(database.connectionString);
|
|
100
|
+
const prisma = createPrisma({ connectionString: database.connectionString });
|
|
101
|
+
try {
|
|
102
|
+
assert.deepEqual(await prisma.$queryRaw\`SELECT 1 AS one\`, [{ one: 1 }]);
|
|
103
|
+
} finally {
|
|
104
|
+
await prisma.$disconnect();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
export function eslintConfig(projectRoot, rootOffset) {
|
|
110
|
+
return `import baseConfig, { modernNodeRecommended } from '${rootOffset}eslint.config.mjs';
|
|
111
|
+
|
|
112
|
+
export default [
|
|
113
|
+
// The generate target writes the client here.
|
|
114
|
+
{ ignores: ['src/prisma/**'] },
|
|
115
|
+
...baseConfig,
|
|
116
|
+
...modernNodeRecommended,
|
|
117
|
+
// No tsconfig of the project includes prisma.config.ts, so typed lint gives
|
|
118
|
+
// it the default project. The path is relative to the workspace root, the
|
|
119
|
+
// tsconfigRootDir of @zukhruf/eslint. The block takes each .ts file, as the
|
|
120
|
+
// root block does: one project service serves the process, with the options
|
|
121
|
+
// of the first file it parses.
|
|
122
|
+
{
|
|
123
|
+
files: ['**/*.ts'],
|
|
124
|
+
languageOptions: {
|
|
125
|
+
parserOptions: {
|
|
126
|
+
projectService: {
|
|
127
|
+
allowDefaultProject: ['${projectRoot}/prisma.config.ts'],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
export const envExample = `# Copy to \`.env\` (gitignored). Nx loads it into each task of this project, so
|
|
136
|
+
# \`nx run <project>:migrate\` and \`deploy\` need no dotenv.
|
|
137
|
+
CONNECTION_STRING=
|
|
138
|
+
# Optional: the shadow database of \`prisma migrate dev\`.
|
|
139
|
+
SHADOW_CONNECTION_STRING=
|
|
140
|
+
`;
|
|
141
|
+
export function migrationDockerfile(options) {
|
|
142
|
+
const { projectRoot, packageName } = options;
|
|
143
|
+
return `# syntax=docker/dockerfile:1.7-labs
|
|
144
|
+
# @zukhruf/nx:prisma writes this file. Build from the workspace root:
|
|
145
|
+
# \`docker build --file ${projectRoot}/Dockerfile.migration .\`. The container
|
|
146
|
+
# gets CONNECTION_STRING from its environment and applies the migrations.
|
|
147
|
+
|
|
148
|
+
FROM node:lts-alpine
|
|
149
|
+
# The lockfile is the latest npm's; the image's bundled npm can be older and
|
|
150
|
+
# resolve peer ranges differently, so it must not decide the tree.
|
|
151
|
+
RUN npm install -g npm@latest
|
|
152
|
+
WORKDIR /workspace
|
|
153
|
+
# npm ci checks the lockfile against the root manifest, its .npmrc and every
|
|
154
|
+
# workspace manifest. It installs the closure of ${packageName}, whose
|
|
155
|
+
# devDependencies hold the Prisma CLI, so the CLI is the version of the
|
|
156
|
+
# lockfile. allowScripts runs @prisma/engines, which downloads the schema
|
|
157
|
+
# engine that migrate deploy runs.
|
|
158
|
+
COPY package-lock.json package.json .npmrc ./
|
|
159
|
+
COPY --parents **/package.json ./
|
|
160
|
+
RUN npm ci --workspace=${packageName} --no-audit --no-fund
|
|
161
|
+
|
|
162
|
+
WORKDIR /workspace/${projectRoot}
|
|
163
|
+
COPY ${projectRoot}/prisma.config.ts ${projectRoot}/schema.prisma ./
|
|
164
|
+
COPY ${projectRoot}/models ./models
|
|
165
|
+
COPY ${projectRoot}/migrations ./migrations
|
|
166
|
+
|
|
167
|
+
CMD ["npx", "prisma", "migrate", "deploy"]
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
/** The lines that a backend's startup.ts gets: the client, connected before the app serves. */
|
|
171
|
+
export function startupClientTs(packageName) {
|
|
172
|
+
return `import { createPrisma } from '${packageName}';
|
|
173
|
+
|
|
174
|
+
// One query before the app serves, so a database that refuses the
|
|
175
|
+
// CONNECTION_STRING stops the boot. $connect() is not enough: on a driver
|
|
176
|
+
// adapter it opens no connection. server.ts disconnects on SIGTERM.
|
|
177
|
+
export const prisma = createPrisma({
|
|
178
|
+
connectionString: process.env.CONNECTION_STRING,
|
|
179
|
+
});
|
|
180
|
+
await prisma.$queryRaw\`SELECT 1\`;
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/prisma/files.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,+DAA+D;AAE/D,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;CAW3B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;CAe7B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;CAGhC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;CAgBtB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCxB,CAAC;AAEF,mEAAmE;AACnE,MAAM,UAAU,cAAc,CAAC,OAG9B;IACC,OAAO;;;;;gCAKuB,OAAO,CAAC,MAAM;+BACf,OAAO,CAAC,OAAO;;;;;;;;;;;;;;CAc7C,CAAC;AACF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,UAAkB;IAClE,OAAO,sDAAsD,UAAU;;;;;;;;;;;;;;;;;mCAiBtC,WAAW;;;;;;CAM7C,CAAC;AACF,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;CAKzB,CAAC;AAOF,MAAM,UAAU,mBAAmB,CACjC,OAAmC;IAEnC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAC7C,OAAO;;0BAEiB,WAAW;;;;;;;;;mDASc,WAAW;;;;;;yBAMrC,WAAW;;qBAEf,WAAW;OACzB,WAAW,qBAAqB,WAAW;OAC3C,WAAW;OACX,WAAW;;;CAGjB,CAAC;AACF,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,eAAe,CAAC,WAAmB;IACjD,OAAO,iCAAiC,WAAW;;;;;;;;;CASpD,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
|
+
export interface PrismaOptions {
|
|
3
|
+
/** The project root of the db package, for example `packages/db`. */
|
|
4
|
+
directory: string;
|
|
5
|
+
/** The project root of a node-app that connects to the database before it serves, for example `apps/backend`. */
|
|
6
|
+
backend?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A Postgres db package on Prisma 7 and @prisma/adapter-pg: the schema, the
|
|
10
|
+
* config, the migrations folder, a client module, a test helper that applies
|
|
11
|
+
* the migrations, and an image that runs `prisma migrate deploy`. The targets
|
|
12
|
+
* come from @zukhruf/nx/prisma. With `backend`, the node-app connects to the
|
|
13
|
+
* database before it serves. It runs `init` first. A second run keeps the
|
|
14
|
+
* files of the package.
|
|
15
|
+
*/
|
|
16
|
+
export default function prismaGenerator(tree: Tree, options: PrismaOptions): Promise<GeneratorCallback>;
|
|
17
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/prisma/generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,IAAI,EAOV,MAAM,YAAY,CAAC;AA0BpB,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,iHAAiH;IACjH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA4BD;;;;;;;GAOG;AACH,wBAA8B,eAAe,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,iBAAiB,CAAC,CA4D5B"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import { formatFiles, installPackagesTask, readJson, runTasksInSerial, updateJson, writeJson, } from '@nx/devkit';
|
|
3
|
+
import { addLines } from "../add-lines.js";
|
|
4
|
+
import { appDirectory } from "../app-directory.js";
|
|
5
|
+
import initGenerator from "../init/generator.js";
|
|
6
|
+
import { pluginName, unique, updateTargetDefault } from "../init/nx-json.js";
|
|
7
|
+
import { dockerignore, startupTs } from "../node-app/files.js";
|
|
8
|
+
import { rootDependencyNames, settleRootDependencies, } from "../root-dependencies.js";
|
|
9
|
+
import { appPackageVersions as versions, zukhrufVersion } from "../versions.js";
|
|
10
|
+
import { workspaceScope } from "../workspace-scope.js";
|
|
11
|
+
import { databaseTestTs, envExample, eslintConfig, indexTs, migrationDockerfile, migrationLockToml, prismaConfigTs, schemaPrisma, startupClientTs, testingTs, } from "./files.js";
|
|
12
|
+
/**
|
|
13
|
+
* The npm packages of the db package. A backend bundles the package, so its
|
|
14
|
+
* deploy manifest declares them in place of the package (ADR 0011).
|
|
15
|
+
*/
|
|
16
|
+
const packageDependencies = {
|
|
17
|
+
'@prisma/adapter-pg': versions['@prisma/adapter-pg'],
|
|
18
|
+
'@prisma/client': versions['@prisma/client'],
|
|
19
|
+
pg: versions.pg,
|
|
20
|
+
// importHelpers of the base: the emitted JavaScript imports tslib.
|
|
21
|
+
tslib: versions.tslib,
|
|
22
|
+
};
|
|
23
|
+
const exportOf = (entry) => ({
|
|
24
|
+
development: `./src/${entry}.ts`,
|
|
25
|
+
types: `./dist/${entry}.d.ts`,
|
|
26
|
+
import: `./dist/${entry}.js`,
|
|
27
|
+
default: `./dist/${entry}.js`,
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* A Postgres db package on Prisma 7 and @prisma/adapter-pg: the schema, the
|
|
31
|
+
* config, the migrations folder, a client module, a test helper that applies
|
|
32
|
+
* the migrations, and an image that runs `prisma migrate deploy`. The targets
|
|
33
|
+
* come from @zukhruf/nx/prisma. With `backend`, the node-app connects to the
|
|
34
|
+
* database before it serves. It runs `init` first. A second run keeps the
|
|
35
|
+
* files of the package.
|
|
36
|
+
*/
|
|
37
|
+
export default async function prismaGenerator(tree, options) {
|
|
38
|
+
const initTask = await initGenerator(tree);
|
|
39
|
+
const scope = workspaceScope(tree);
|
|
40
|
+
const { projectRoot, name, rootOffset } = appDirectory(options.directory);
|
|
41
|
+
const packageName = `@${scope}/${name}`;
|
|
42
|
+
const backendRoot = options.backend === undefined
|
|
43
|
+
? undefined
|
|
44
|
+
: appDirectory(options.backend).projectRoot;
|
|
45
|
+
if (backendRoot !== undefined &&
|
|
46
|
+
!tree.exists(`${backendRoot}/sdk-it.config.ts`)) {
|
|
47
|
+
throw new Error(`${backendRoot} has no sdk-it.config.ts, so it is not a node-app. Run @zukhruf/nx:node-app ${backendRoot} first.`);
|
|
48
|
+
}
|
|
49
|
+
const before = rootDependencyNames(tree);
|
|
50
|
+
const packageJsonPath = `${projectRoot}/package.json`;
|
|
51
|
+
if (tree.exists(packageJsonPath)) {
|
|
52
|
+
const existing = readJson(tree, packageJsonPath);
|
|
53
|
+
if (existing.name !== packageName) {
|
|
54
|
+
throw new Error(existing.name === undefined
|
|
55
|
+
? `${packageJsonPath} already exists and has no name.`
|
|
56
|
+
: `${projectRoot} already belongs to ${existing.name}.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
writePackage(tree, { projectRoot, rootOffset, packageName });
|
|
61
|
+
}
|
|
62
|
+
addWorkspace(tree, projectRoot);
|
|
63
|
+
addLines(tree, '.gitignore', `${projectRoot}/src/prisma\n`);
|
|
64
|
+
addLines(tree, '.prettierignore', `${projectRoot}/src/prisma\n`);
|
|
65
|
+
if (!tree.exists('.dockerignore')) {
|
|
66
|
+
tree.write('.dockerignore', dockerignore);
|
|
67
|
+
}
|
|
68
|
+
mergePrismaNxJson(tree);
|
|
69
|
+
if (backendRoot !== undefined) {
|
|
70
|
+
wireBackend(tree, backendRoot, packageName);
|
|
71
|
+
}
|
|
72
|
+
settleRootDependencies(tree, before, {
|
|
73
|
+
// The tests of a db package and of its backend take a database from it.
|
|
74
|
+
devDependencies: { '@zukhruf/testing': zukhrufVersion },
|
|
75
|
+
// @prisma/engines downloads the schema engine that migrate deploy runs.
|
|
76
|
+
// The preinstall of prisma only checks the Node version. @zukhruf/testing
|
|
77
|
+
// brings ssh2, whose native crypto binding and cpu-features are optional:
|
|
78
|
+
// ssh2 falls back to JavaScript, as in zukhruf, factory and text2sql.
|
|
79
|
+
allowScripts: {
|
|
80
|
+
'@prisma/engines': true,
|
|
81
|
+
prisma: false,
|
|
82
|
+
ssh2: false,
|
|
83
|
+
'cpu-features': false,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
await formatFiles(tree);
|
|
87
|
+
return runTasksInSerial(initTask, () => installPackagesTask(tree));
|
|
88
|
+
}
|
|
89
|
+
function writePackage(tree, identity) {
|
|
90
|
+
const { projectRoot, rootOffset, packageName } = identity;
|
|
91
|
+
writeJson(tree, `${projectRoot}/package.json`, {
|
|
92
|
+
name: packageName,
|
|
93
|
+
version: '0.0.1',
|
|
94
|
+
private: true,
|
|
95
|
+
type: 'module',
|
|
96
|
+
main: './dist/index.js',
|
|
97
|
+
module: './dist/index.js',
|
|
98
|
+
types: './dist/index.d.ts',
|
|
99
|
+
exports: {
|
|
100
|
+
'./package.json': './package.json',
|
|
101
|
+
'.': exportOf('index'),
|
|
102
|
+
'./testing': exportOf('testing'),
|
|
103
|
+
},
|
|
104
|
+
dependencies: packageDependencies,
|
|
105
|
+
// The migration image installs the CLI from here.
|
|
106
|
+
devDependencies: {
|
|
107
|
+
'@types/pg': versions['@types/pg'],
|
|
108
|
+
prisma: versions.prisma,
|
|
109
|
+
},
|
|
110
|
+
nx: { tags: ['test:docker'] },
|
|
111
|
+
});
|
|
112
|
+
const base = `${rootOffset}tsconfig.base.json`;
|
|
113
|
+
writeJson(tree, `${projectRoot}/tsconfig.json`, {
|
|
114
|
+
extends: base,
|
|
115
|
+
files: [],
|
|
116
|
+
include: [],
|
|
117
|
+
references: [
|
|
118
|
+
{ path: './tsconfig.lib.json' },
|
|
119
|
+
{ path: './tsconfig.test.json' },
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
// The base emits declarations only. The build emits JavaScript too, and
|
|
123
|
+
// rewrites the `.ts` imports of the generated client to `.js`.
|
|
124
|
+
writeJson(tree, `${projectRoot}/tsconfig.lib.json`, {
|
|
125
|
+
extends: base,
|
|
126
|
+
compilerOptions: {
|
|
127
|
+
outDir: 'dist',
|
|
128
|
+
rootDir: 'src',
|
|
129
|
+
tsBuildInfoFile: 'dist/tsconfig.lib.tsbuildinfo',
|
|
130
|
+
emitDeclarationOnly: false,
|
|
131
|
+
rewriteRelativeImportExtensions: true,
|
|
132
|
+
types: ['node'],
|
|
133
|
+
},
|
|
134
|
+
include: ['src/**/*.ts'],
|
|
135
|
+
exclude: ['src/**/*.test.ts'],
|
|
136
|
+
});
|
|
137
|
+
writeJson(tree, `${projectRoot}/tsconfig.test.json`, {
|
|
138
|
+
extends: base,
|
|
139
|
+
compilerOptions: {
|
|
140
|
+
outDir: 'out-tsc',
|
|
141
|
+
rootDir: 'src',
|
|
142
|
+
tsBuildInfoFile: 'out-tsc/tsconfig.test.tsbuildinfo',
|
|
143
|
+
types: ['node'],
|
|
144
|
+
},
|
|
145
|
+
include: ['src/**/*.test.ts'],
|
|
146
|
+
references: [{ path: './tsconfig.lib.json' }],
|
|
147
|
+
});
|
|
148
|
+
tree.write(`${projectRoot}/eslint.config.mjs`, eslintConfig(projectRoot, rootOffset));
|
|
149
|
+
tree.write(`${projectRoot}/prisma.config.ts`, prismaConfigTs);
|
|
150
|
+
tree.write(`${projectRoot}/schema.prisma`, schemaPrisma);
|
|
151
|
+
// The migration image copies models/, so it is in Git before the first model.
|
|
152
|
+
tree.write(`${projectRoot}/models/.gitkeep`, '');
|
|
153
|
+
tree.write(`${projectRoot}/migrations/migration_lock.toml`, migrationLockToml);
|
|
154
|
+
tree.write(`${projectRoot}/src/index.ts`, indexTs);
|
|
155
|
+
tree.write(`${projectRoot}/src/testing.ts`, testingTs);
|
|
156
|
+
tree.write(`${projectRoot}/src/index.test.ts`, databaseTestTs({ client: './index.ts', testing: './testing.ts' }));
|
|
157
|
+
tree.write(`${projectRoot}/.env.example`, envExample);
|
|
158
|
+
if (!tree.exists(`${projectRoot}/.env`)) {
|
|
159
|
+
tree.write(`${projectRoot}/.env`, envExample);
|
|
160
|
+
}
|
|
161
|
+
tree.write(`${projectRoot}/Dockerfile.migration`, migrationDockerfile({ projectRoot, packageName }));
|
|
162
|
+
}
|
|
163
|
+
/** `npm ci --workspace` of the migration image needs the package in `workspaces`. */
|
|
164
|
+
function addWorkspace(tree, projectRoot) {
|
|
165
|
+
updateJson(tree, 'package.json', (packageJson) => {
|
|
166
|
+
const workspaces = packageJson.workspaces ?? [];
|
|
167
|
+
if (!workspaces.includes(projectRoot) &&
|
|
168
|
+
!workspaces.includes(`${posix.dirname(projectRoot)}/*`)) {
|
|
169
|
+
packageJson.workspaces = [...workspaces, projectRoot];
|
|
170
|
+
}
|
|
171
|
+
return packageJson;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The plugin gives the Prisma targets, and `generate` runs before each
|
|
176
|
+
* typecheck and build, because the client is not committed (ADR 0008). Nx
|
|
177
|
+
* skips a dependency on a target that the project does not have, and `...`
|
|
178
|
+
* keeps the dependencies that the plugins infer.
|
|
179
|
+
*/
|
|
180
|
+
function mergePrismaNxJson(tree) {
|
|
181
|
+
updateJson(tree, 'nx.json', (nxJson) => {
|
|
182
|
+
const plugins = nxJson.plugins ?? [];
|
|
183
|
+
if (!plugins.some((entry) => pluginName(entry) === '@zukhruf/nx/prisma')) {
|
|
184
|
+
nxJson.plugins = [...plugins, '@zukhruf/nx/prisma'];
|
|
185
|
+
}
|
|
186
|
+
for (const target of ['typecheck', 'build']) {
|
|
187
|
+
updateTargetDefault(nxJson, target, (entry) => ({
|
|
188
|
+
...entry,
|
|
189
|
+
dependsOn: unique([...(entry.dependsOn ?? []), 'generate', '...']),
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
return nxJson;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/** Adds `KEY=` to an env file that has no line for the key. */
|
|
196
|
+
function addEnvKey(tree, path, key) {
|
|
197
|
+
const content = tree.read(path, 'utf-8') ?? '';
|
|
198
|
+
if (new RegExp(`^${key}=`, 'm').test(content))
|
|
199
|
+
return;
|
|
200
|
+
addLines(tree, path, `${key}=\n`);
|
|
201
|
+
}
|
|
202
|
+
/** Replaces `marker` in a file of the backend, or stops when the file has no marker. */
|
|
203
|
+
function insert(tree, path, marker, replacement) {
|
|
204
|
+
const content = tree.read(path, 'utf-8');
|
|
205
|
+
if (content === null || !content.includes(marker)) {
|
|
206
|
+
throw new Error(`${path} has no ${JSON.stringify(marker)}, so the generator cannot wire the database into it.`);
|
|
207
|
+
}
|
|
208
|
+
tree.write(path, content.replace(marker, replacement));
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The backend declares CONNECTION_STRING, connects the client in startup.ts
|
|
212
|
+
* before it serves, and disconnects it when terminus gets SIGTERM. Each step
|
|
213
|
+
* is skipped when the backend already has it.
|
|
214
|
+
*/
|
|
215
|
+
function wireBackend(tree, backendRoot, packageName) {
|
|
216
|
+
const envPath = `${backendRoot}/src/env.ts`;
|
|
217
|
+
if (!tree.read(envPath, 'utf-8')?.includes('CONNECTION_STRING:')) {
|
|
218
|
+
insert(tree, envPath, 'const env = z.object({\n', `const env = z.object({\n // The Postgres database of ${packageName}.\n CONNECTION_STRING: z.string().min(1),\n`);
|
|
219
|
+
}
|
|
220
|
+
addEnvKey(tree, `${backendRoot}/.env.example`, 'CONNECTION_STRING');
|
|
221
|
+
if (tree.exists(`${backendRoot}/.env`)) {
|
|
222
|
+
addEnvKey(tree, `${backendRoot}/.env`, 'CONNECTION_STRING');
|
|
223
|
+
}
|
|
224
|
+
const startupPath = `${backendRoot}/src/startup.ts`;
|
|
225
|
+
const startup = tree.read(startupPath, 'utf-8') ?? '';
|
|
226
|
+
if (!startup.includes(`from '${packageName}'`)) {
|
|
227
|
+
// The placeholder of node-app goes; a startup.ts with code keeps it.
|
|
228
|
+
tree.write(startupPath, startup === startupTs
|
|
229
|
+
? `import './env.ts';\n\n${startupClientTs(packageName)}`
|
|
230
|
+
: `${startup}\n${startupClientTs(packageName)}`);
|
|
231
|
+
}
|
|
232
|
+
const serverPath = `${backendRoot}/src/server.ts`;
|
|
233
|
+
if (!tree.read(serverPath, 'utf-8')?.includes('prisma.$disconnect()')) {
|
|
234
|
+
insert(tree, serverPath, "import './startup.ts';", "import { prisma } from './startup.ts';");
|
|
235
|
+
insert(tree, serverPath, ' await flushLogs();\n', ' await prisma.$disconnect();\n await flushLogs();\n');
|
|
236
|
+
}
|
|
237
|
+
updateJson(tree, `${backendRoot}/package.json`, (packageJson) => {
|
|
238
|
+
// The esbuild bundle inlines the db package and leaves its npm packages
|
|
239
|
+
// external, so prune-lockfile and dependency-checks need them here.
|
|
240
|
+
packageJson.dependencies = {
|
|
241
|
+
...packageJson.dependencies,
|
|
242
|
+
...packageDependencies,
|
|
243
|
+
};
|
|
244
|
+
packageJson.nx = {
|
|
245
|
+
...packageJson.nx,
|
|
246
|
+
tags: unique([...(packageJson.nx?.tags ?? []), 'test:docker']),
|
|
247
|
+
};
|
|
248
|
+
return packageJson;
|
|
249
|
+
});
|
|
250
|
+
const testPath = `${backendRoot}/src/database.test.ts`;
|
|
251
|
+
if (!tree.exists(testPath)) {
|
|
252
|
+
tree.write(testPath, databaseTestTs({
|
|
253
|
+
client: packageName,
|
|
254
|
+
testing: `${packageName}/testing`,
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/prisma/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAIL,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,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,WAAW,CAAC;IACrB,CAAC,CACF,CAAC;IACF,MAAM,QAAQ,GAAG,GAAG,WAAW,uBAAuB,CAAC;IACvD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CACR,QAAQ,EACR,cAAc,CAAC;YACb,MAAM,EAAE,WAAW;YACnB,OAAO,EAAE,GAAG,WAAW,UAAU;SAClC,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function indexHtml(name: string): string;
|
|
2
|
+
export declare const stylesCss = "@import \"tailwindcss\";\n\n/* nx-tailwind-sources:start */\n/* nx-tailwind-sources:end */\n\n/* The theme script in index.html sets .dark; dark: utilities follow it. */\n@custom-variant dark (&:is(.dark, .dark *));\n";
|
|
3
|
+
export declare function appTsx(name: string): string;
|
|
4
|
+
export declare const appTestTsx = "import { cleanup, render, screen } from '@testing-library/react';\nimport { expect, test } from 'vitest';\n\nimport App from './app.tsx';\n\ntest('renders the welcome heading', () => {\n try {\n render(<App />);\n expect(screen.getByRole('heading')).toHaveTextContent(/welcome/i);\n } finally {\n cleanup();\n }\n});\n";
|
|
5
|
+
export declare const mainTsx = "import { StrictMode } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { createBrowserRouter } from 'react-router';\nimport { RouterProvider } from 'react-router/dom';\n\nimport App from './app/app.tsx';\nimport './styles.css';\n\nconst router = createBrowserRouter([{ path: '/', Component: App }]);\n\nconst rootElement = document.getElementById('root');\nif (!rootElement) {\n throw new Error('Missing root element.');\n}\n\ncreateRoot(rootElement).render(\n <StrictMode>\n <RouterProvider router={router} />\n </StrictMode>,\n);\n";
|
|
6
|
+
export declare function viteConfig(name: string, projectRoot: string, rootOffset: string): string;
|
|
7
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/react-app/files.ts"],"names":[],"mappings":"AAMA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkC9C;AAED,eAAO,MAAM,SAAS,8NAOrB,CAAC;AAEF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO3C;AAED,eAAO,MAAM,UAAU,+UAatB,CAAC;AAEF,eAAO,MAAM,OAAO,qjBAoBnB,CAAC;AAEF,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM,CA+FR"}
|