@zukhruf/nx 0.8.30 → 0.8.32
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 +375 -19
- 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 +23 -0
- package/dist/generators/dokploy/files.d.ts.map +1 -0
- package/dist/generators/dokploy/files.js +733 -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 +146 -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.map +1 -1
- package/dist/generators/init/files.js +11 -5
- package/dist/generators/init/files.js.map +1 -1
- package/dist/generators/init/generator.d.ts.map +1 -1
- package/dist/generators/init/generator.js +1 -16
- package/dist/generators/init/generator.js.map +1 -1
- package/dist/generators/init/nx-json.d.ts +16 -3
- package/dist/generators/init/nx-json.d.ts.map +1 -1
- package/dist/generators/init/nx-json.js +20 -5
- package/dist/generators/init/nx-json.js.map +1 -1
- package/dist/generators/init/root-package-json.d.ts +6 -0
- package/dist/generators/init/root-package-json.d.ts.map +1 -1
- package/dist/generators/init/root-package-json.js +15 -12
- package/dist/generators/init/root-package-json.js.map +1 -1
- 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 +322 -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/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 +243 -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 +30 -0
- package/dist/generators/root-dependencies.d.ts.map +1 -0
- package/dist/generators/root-dependencies.js +63 -0
- package/dist/generators/root-dependencies.js.map +1 -0
- package/dist/generators/ui-package/files.d.ts +39 -0
- package/dist/generators/ui-package/files.d.ts.map +1 -0
- package/dist/generators/ui-package/files.js +163 -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 +116 -0
- package/dist/generators/ui-package/generator.js.map +1 -0
- package/dist/generators/versions.d.ts +50 -1
- package/dist/generators/versions.d.ts.map +1 -1
- package/dist/generators/versions.js +64 -1
- package/dist/generators/versions.js.map +1 -1
- package/generators.json +30 -0
- package/package.json +24 -5
- package/src/generators/dokploy/schema.json +48 -0
- package/src/generators/node-app/schema.json +22 -0
- package/src/generators/pair/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,188 @@
|
|
|
1
|
+
// The content of each file that react-app writes into the project. Each is a
|
|
2
|
+
// string in a .ts module, so tsc puts it in dist with no copy step (ADR 0009).
|
|
3
|
+
// The brand of a product (fonts, colors, favicons) is the product's own. The
|
|
4
|
+
// theme script and the `dark` variant are not brand: the monorepo standard
|
|
5
|
+
// puts them in every web app, and the owner kept them (ADR 0010, decision 1).
|
|
6
|
+
export function indexHtml(name) {
|
|
7
|
+
return `<!doctype html>
|
|
8
|
+
<html lang="en">
|
|
9
|
+
<head>
|
|
10
|
+
<meta charset="utf-8" />
|
|
11
|
+
<title>${name}</title>
|
|
12
|
+
<base href="/" />
|
|
13
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
14
|
+
<script>
|
|
15
|
+
// Sets the light or dark class before the first paint: the stored
|
|
16
|
+
// choice, or the system's when the choice is "system" or missing.
|
|
17
|
+
(function () {
|
|
18
|
+
try {
|
|
19
|
+
var stored = localStorage.getItem('theme');
|
|
20
|
+
var theme =
|
|
21
|
+
stored === 'light' || stored === 'dark' || stored === 'system'
|
|
22
|
+
? stored
|
|
23
|
+
: 'system';
|
|
24
|
+
var dark =
|
|
25
|
+
theme === 'dark' ||
|
|
26
|
+
(theme === 'system' &&
|
|
27
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
28
|
+
document.documentElement.classList.add(dark ? 'dark' : 'light');
|
|
29
|
+
} catch (e) {}
|
|
30
|
+
})();
|
|
31
|
+
</script>
|
|
32
|
+
<link rel="stylesheet" href="/src/styles.css" />
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
35
|
+
<div id="root"></div>
|
|
36
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
export const stylesCss = `@import "tailwindcss";
|
|
42
|
+
|
|
43
|
+
/* nx-tailwind-sources:start */
|
|
44
|
+
/* nx-tailwind-sources:end */
|
|
45
|
+
|
|
46
|
+
/* The theme script in index.html sets .dark; dark: utilities follow it. */
|
|
47
|
+
@custom-variant dark (&:is(.dark, .dark *));
|
|
48
|
+
`;
|
|
49
|
+
export function appTsx(name) {
|
|
50
|
+
return `export function App() {
|
|
51
|
+
return <h1>Welcome to ${name}</h1>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default App;
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
export const appTestTsx = `import { cleanup, render, screen } from '@testing-library/react';
|
|
58
|
+
import { expect, test } from 'vitest';
|
|
59
|
+
|
|
60
|
+
import App from './app.tsx';
|
|
61
|
+
|
|
62
|
+
test('renders the welcome heading', () => {
|
|
63
|
+
try {
|
|
64
|
+
render(<App />);
|
|
65
|
+
expect(screen.getByRole('heading')).toHaveTextContent(/welcome/i);
|
|
66
|
+
} finally {
|
|
67
|
+
cleanup();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
`;
|
|
71
|
+
export const mainTsx = `import { StrictMode } from 'react';
|
|
72
|
+
import { createRoot } from 'react-dom/client';
|
|
73
|
+
import { createBrowserRouter } from 'react-router';
|
|
74
|
+
import { RouterProvider } from 'react-router/dom';
|
|
75
|
+
|
|
76
|
+
import App from './app/app.tsx';
|
|
77
|
+
import './styles.css';
|
|
78
|
+
|
|
79
|
+
const router = createBrowserRouter([{ path: '/', Component: App }]);
|
|
80
|
+
|
|
81
|
+
const rootElement = document.getElementById('root');
|
|
82
|
+
if (!rootElement) {
|
|
83
|
+
throw new Error('Missing root element.');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
createRoot(rootElement).render(
|
|
87
|
+
<StrictMode>
|
|
88
|
+
<RouterProvider router={router} />
|
|
89
|
+
</StrictMode>,
|
|
90
|
+
);
|
|
91
|
+
`;
|
|
92
|
+
export function viteConfig(name, projectRoot, rootOffset) {
|
|
93
|
+
return `/// <reference types='vitest' />
|
|
94
|
+
import { constants as zlibConstants } from 'node:zlib';
|
|
95
|
+
|
|
96
|
+
import babel from '@rolldown/plugin-babel';
|
|
97
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
98
|
+
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
|
|
99
|
+
import { defineConfig } from 'vite';
|
|
100
|
+
import { compression, defineAlgorithm } from 'vite-plugin-compression2';
|
|
101
|
+
|
|
102
|
+
export default defineConfig(({ mode }) => {
|
|
103
|
+
const enableSourceMaps =
|
|
104
|
+
process.env.VITE_SOURCEMAP === 'true' || process.env.SOURCEMAP === 'true';
|
|
105
|
+
const isVitest = mode === 'test' || process.env.VITEST === 'true';
|
|
106
|
+
// Set by portless only when it launches the dev server; unlike PORT it
|
|
107
|
+
// cannot be set by a stray shell env.
|
|
108
|
+
const underPortless = Boolean(process.env.PORTLESS_URL);
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
root: import.meta.dirname,
|
|
112
|
+
cacheDir: '${rootOffset}node_modules/.vite/${projectRoot}',
|
|
113
|
+
server: {
|
|
114
|
+
port: underPortless && process.env.PORT ? Number(process.env.PORT) : 5173,
|
|
115
|
+
// portless dials 127.0.0.1; 'localhost' binds ::1-only on macOS (IPv6
|
|
116
|
+
// first) so the proxy can't reach it. Bind IPv4 explicitly under
|
|
117
|
+
// portless.
|
|
118
|
+
host: underPortless ? '127.0.0.1' : 'localhost',
|
|
119
|
+
allowedHosts: ['.localhost', '.trycloudflare.com'],
|
|
120
|
+
hmr: underPortless ? { clientPort: 443, protocol: 'wss' } : undefined,
|
|
121
|
+
// Forward browser console output and uncaught errors over the HMR socket
|
|
122
|
+
// into this process's stdout, so a transcript of the dev server (see the
|
|
123
|
+
// portless target) is enough to read what the page logged. Vite's default
|
|
124
|
+
// only turns this on when it detects an agent in the environment.
|
|
125
|
+
forwardConsole: {
|
|
126
|
+
logLevels: ['error', 'warn', 'info', 'log'],
|
|
127
|
+
},
|
|
128
|
+
// Development reaches the API through the dev server, so cookies and
|
|
129
|
+
// relative URLs behave as in production, where the paired node app
|
|
130
|
+
// serves this SPA from its own origin. Override when the API listens
|
|
131
|
+
// elsewhere.
|
|
132
|
+
proxy: {
|
|
133
|
+
'/api': {
|
|
134
|
+
target: process.env.API_PROXY_TARGET ?? 'http://127.0.0.1:3000',
|
|
135
|
+
changeOrigin: false,
|
|
136
|
+
ws: true,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
plugins: [
|
|
141
|
+
react({
|
|
142
|
+
// Passing \`exclude\` replaces plugin-react's default /\\/node_modules\\//
|
|
143
|
+
// filter, so it must be restated alongside the workspace dist exclude.
|
|
144
|
+
exclude: [/\\/dist\\//, /\\/node_modules\\//],
|
|
145
|
+
}),
|
|
146
|
+
babel({ presets: [reactCompilerPreset()] }),
|
|
147
|
+
tailwindcss(),
|
|
148
|
+
!isVitest &&
|
|
149
|
+
compression({
|
|
150
|
+
threshold: 1024,
|
|
151
|
+
skipIfLargerOrEqual: true,
|
|
152
|
+
algorithms: [
|
|
153
|
+
defineAlgorithm('brotliCompress', {
|
|
154
|
+
params: { [zlibConstants.BROTLI_PARAM_QUALITY]: 11 },
|
|
155
|
+
}),
|
|
156
|
+
defineAlgorithm('gzip', { level: 9 }),
|
|
157
|
+
],
|
|
158
|
+
}),
|
|
159
|
+
],
|
|
160
|
+
base: './',
|
|
161
|
+
build: {
|
|
162
|
+
outDir: './dist',
|
|
163
|
+
emptyOutDir: true,
|
|
164
|
+
reportCompressedSize: true,
|
|
165
|
+
sourcemap: enableSourceMaps,
|
|
166
|
+
commonjsOptions: { transformMixedEsModules: true },
|
|
167
|
+
},
|
|
168
|
+
test: {
|
|
169
|
+
name: '${name}',
|
|
170
|
+
watch: false,
|
|
171
|
+
globals: false,
|
|
172
|
+
environment: 'happy-dom',
|
|
173
|
+
pool: 'forks',
|
|
174
|
+
execArgv: ['--no-experimental-webstorage'],
|
|
175
|
+
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
176
|
+
setupFiles: ['@testing-library/jest-dom/vitest'],
|
|
177
|
+
reporters: ['default', 'junit'],
|
|
178
|
+
outputFile: { junit: './test-results.xml' },
|
|
179
|
+
coverage: {
|
|
180
|
+
reportsDirectory: '${rootOffset}coverage/${projectRoot}',
|
|
181
|
+
provider: 'v8' as const,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/react-app/files.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAE9E,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO;;;;aAII,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BhB,CAAC;AACF,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;CAOxB,CAAC;AAEF,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO;0BACiB,IAAI;;;;CAI7B,CAAC;AACF,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;CAazB,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;CAoBtB,CAAC;AAEF,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,WAAmB,EACnB,UAAkB;IAElB,OAAO;;;;;;;;;;;;;;;;;;;iBAmBQ,UAAU,sBAAsB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAyD7C,IAAI;;;;;;;;;;;6BAWU,UAAU,YAAY,WAAW;;;;;;CAM7D,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
|
+
export interface ReactAppOptions {
|
|
3
|
+
/** The project root, for example `apps/web`. */
|
|
4
|
+
directory: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A React Router 8 SPA in data mode on Vite: React Compiler, Tailwind 4,
|
|
8
|
+
* precompressed assets, a dev proxy to `/api`, and Vitest component tests.
|
|
9
|
+
* It runs `init` first.
|
|
10
|
+
*/
|
|
11
|
+
export default function reactAppGenerator(tree: Tree, options: ReactAppOptions): Promise<GeneratorCallback>;
|
|
12
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/react-app/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,IAAI,EAMV,MAAM,YAAY,CAAC;AAiCpB,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB;AAsBD;;;;GAIG;AACH,wBAA8B,iBAAiB,CAC7C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,iBAAiB,CAAC,CA+E5B"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { formatFiles, installPackagesTask, readJson, runTasksInSerial, updateJson, } from '@nx/devkit';
|
|
2
|
+
import { appDirectory, projectNameOf } from "../app-directory.js";
|
|
3
|
+
import initGenerator from "../init/generator.js";
|
|
4
|
+
import { mergeGeneratorDefaults, pluginName, unique, updateTargetDefault, } from "../init/nx-json.js";
|
|
5
|
+
import { nxPlugin } from "../nx-plugin.js";
|
|
6
|
+
import { reactEslintConfig, reactResidue, reactRootPackages, tailwindSyncOverrides, } from "../react.js";
|
|
7
|
+
import { fseventsScript, rootDependencyNames, settleRootDependencies, } from "../root-dependencies.js";
|
|
8
|
+
import { appPackageVersions as versions } from "../versions.js";
|
|
9
|
+
import { workspaceScope } from "../workspace-scope.js";
|
|
10
|
+
import { appTestTsx, appTsx, indexHtml, mainTsx, stylesCss, viteConfig, } from "./files.js";
|
|
11
|
+
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
12
|
+
const tailwindSyncGenerator = '@juristr/nx-tailwind-sync:source-directives';
|
|
13
|
+
/**
|
|
14
|
+
* A React Router 8 SPA in data mode on Vite: React Compiler, Tailwind 4,
|
|
15
|
+
* precompressed assets, a dev proxy to `/api`, and Vitest component tests.
|
|
16
|
+
* It runs `init` first.
|
|
17
|
+
*/
|
|
18
|
+
export default async function reactAppGenerator(tree, options) {
|
|
19
|
+
const initTask = await initGenerator(tree);
|
|
20
|
+
const scope = workspaceScope(tree);
|
|
21
|
+
const { projectRoot, name, rootOffset } = appDirectory(options.directory);
|
|
22
|
+
const before = rootDependencyNames(tree);
|
|
23
|
+
const { applicationGenerator } = nxPlugin('@nx/react');
|
|
24
|
+
const appTask = await applicationGenerator(tree, {
|
|
25
|
+
directory: projectRoot,
|
|
26
|
+
bundler: 'vite',
|
|
27
|
+
style: 'css',
|
|
28
|
+
linter: 'eslint',
|
|
29
|
+
unitTestRunner: 'none',
|
|
30
|
+
e2eTestRunner: 'none',
|
|
31
|
+
routing: false,
|
|
32
|
+
useReactRouter: false,
|
|
33
|
+
strict: true,
|
|
34
|
+
useProjectJson: false,
|
|
35
|
+
addPlugin: true,
|
|
36
|
+
skipFormat: true,
|
|
37
|
+
});
|
|
38
|
+
const projectName = projectNameOf(tree, projectRoot);
|
|
39
|
+
tree.delete(`${projectRoot}/src/app/nx-welcome.tsx`);
|
|
40
|
+
tree.delete(`${projectRoot}/src/app/app.module.css`);
|
|
41
|
+
tree.delete(`${projectRoot}/vite.config.mts`);
|
|
42
|
+
tree.delete(`${projectRoot}/public/favicon.ico`);
|
|
43
|
+
tree.write(`${projectRoot}/index.html`, indexHtml(name));
|
|
44
|
+
tree.write(`${projectRoot}/src/styles.css`, stylesCss);
|
|
45
|
+
tree.write(`${projectRoot}/src/main.tsx`, mainTsx);
|
|
46
|
+
tree.write(`${projectRoot}/src/app/app.tsx`, appTsx(name));
|
|
47
|
+
tree.write(`${projectRoot}/src/app/app.test.tsx`, appTestTsx);
|
|
48
|
+
tree.write(`${projectRoot}/vite.config.ts`, viteConfig(name, projectRoot, rootOffset));
|
|
49
|
+
tree.write(`${projectRoot}/eslint.config.mjs`, reactEslintConfig(rootOffset, ['react-router', 'tailwind']));
|
|
50
|
+
// tsc --build writes to out-tsc, so its output stays out of Vite's dist.
|
|
51
|
+
updateJson(tree, `${projectRoot}/tsconfig.app.json`, (config) => {
|
|
52
|
+
config.compilerOptions = {
|
|
53
|
+
...config.compilerOptions,
|
|
54
|
+
outDir: 'out-tsc',
|
|
55
|
+
tsBuildInfoFile: 'out-tsc/tsconfig.app.tsbuildinfo',
|
|
56
|
+
};
|
|
57
|
+
return config;
|
|
58
|
+
});
|
|
59
|
+
writeProjectPackageJson(tree, { projectRoot, name, projectName, scope });
|
|
60
|
+
const testTask = await addComponentTests(tree, projectRoot, projectName);
|
|
61
|
+
mergeReactNxJson(tree);
|
|
62
|
+
settleRootDependencies(tree, before, {
|
|
63
|
+
devDependencies: {
|
|
64
|
+
...reactRootPackages,
|
|
65
|
+
'@juristr/nx-tailwind-sync': versions['@juristr/nx-tailwind-sync'],
|
|
66
|
+
'@testing-library/dom': versions['@testing-library/dom'],
|
|
67
|
+
'@testing-library/jest-dom': versions['@testing-library/jest-dom'],
|
|
68
|
+
'@testing-library/react': versions['@testing-library/react'],
|
|
69
|
+
'@types/node': versions['@types/node'],
|
|
70
|
+
tslib: versions.tslib,
|
|
71
|
+
'@vitest/coverage-v8': versions['@vitest/coverage-v8'],
|
|
72
|
+
'happy-dom': versions['happy-dom'],
|
|
73
|
+
'prettier-plugin-tailwindcss': versions['prettier-plugin-tailwindcss'],
|
|
74
|
+
vitest: versions.vitest,
|
|
75
|
+
},
|
|
76
|
+
// The UI of Vitest: no target runs it.
|
|
77
|
+
residue: [...reactResidue, '@vitest/ui'],
|
|
78
|
+
allowScripts: fseventsScript,
|
|
79
|
+
overrides: tailwindSyncOverrides,
|
|
80
|
+
});
|
|
81
|
+
await formatFiles(tree);
|
|
82
|
+
await addTailwindPrettierPlugin(tree);
|
|
83
|
+
return runTasksInSerial(initTask, appTask, testTask, () => installPackagesTask(tree));
|
|
84
|
+
}
|
|
85
|
+
function writeProjectPackageJson(tree, app) {
|
|
86
|
+
updateJson(tree, `${app.projectRoot}/package.json`, (packageJson) => {
|
|
87
|
+
packageJson.type = 'module';
|
|
88
|
+
packageJson.sideEffects = false;
|
|
89
|
+
packageJson.scripts = {};
|
|
90
|
+
packageJson.dependencies = {
|
|
91
|
+
...packageJson.dependencies,
|
|
92
|
+
react: versions.react,
|
|
93
|
+
'react-dom': versions['react-dom'],
|
|
94
|
+
'react-router': versions['react-router'],
|
|
95
|
+
};
|
|
96
|
+
packageJson.devDependencies = {
|
|
97
|
+
...packageJson.devDependencies,
|
|
98
|
+
'vite-plugin-compression2': versions['vite-plugin-compression2'],
|
|
99
|
+
};
|
|
100
|
+
packageJson.nx = {
|
|
101
|
+
...packageJson.nx,
|
|
102
|
+
targets: {
|
|
103
|
+
...packageJson.nx?.targets,
|
|
104
|
+
portless: {
|
|
105
|
+
command: `portless --name ${app.name}.${app.scope} -- nx run ${app.projectName}:dev --output-style=stream-without-prefixes`,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
return packageJson;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Vitest component tests. vite.config.ts holds the `test` block, so
|
|
114
|
+
* @nx/vitest writes no Vite config; it registers its plugin, which infers the
|
|
115
|
+
* test target, and writes tsconfig.spec.json.
|
|
116
|
+
*/
|
|
117
|
+
async function addComponentTests(tree, projectRoot, projectName) {
|
|
118
|
+
const testDefault = readJson(tree, 'nx.json')
|
|
119
|
+
.targetDefaults?.['test'];
|
|
120
|
+
const { configurationGenerator } = nxPlugin('@nx/vitest/generators');
|
|
121
|
+
const task = await configurationGenerator(tree, {
|
|
122
|
+
project: projectName,
|
|
123
|
+
uiFramework: 'react',
|
|
124
|
+
testEnvironment: 'happy-dom',
|
|
125
|
+
coverageProvider: 'v8',
|
|
126
|
+
addPlugin: true,
|
|
127
|
+
skipViteConfig: true,
|
|
128
|
+
skipFormat: true,
|
|
129
|
+
});
|
|
130
|
+
updateJson(tree, 'nx.json', (nxJson) => {
|
|
131
|
+
// In a TS solution workspace, @nx/vitest adds ^build to the test default.
|
|
132
|
+
// The test default stays as it was: ["...", "^sdk"] after node-app.
|
|
133
|
+
if (testDefault === undefined) {
|
|
134
|
+
delete nxJson.targetDefaults?.['test'];
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
nxJson.targetDefaults = { ...nxJson.targetDefaults, test: testDefault };
|
|
138
|
+
}
|
|
139
|
+
// `vitest` alone watches in a terminal; the test target runs once.
|
|
140
|
+
nxJson.plugins = (nxJson.plugins ?? []).map((entry) => {
|
|
141
|
+
if (pluginName(entry) !== '@nx/vitest')
|
|
142
|
+
return entry;
|
|
143
|
+
const options = typeof entry === 'object' && isRecord(entry.options)
|
|
144
|
+
? entry.options
|
|
145
|
+
: {};
|
|
146
|
+
return { plugin: '@nx/vitest', options: { ...options, testMode: 'run' } };
|
|
147
|
+
});
|
|
148
|
+
return nxJson;
|
|
149
|
+
});
|
|
150
|
+
// The project target, not a target default: a default with a list entry
|
|
151
|
+
// replaces the cwd, cache and inputs of the inferred target (Nx 24). It
|
|
152
|
+
// builds the generated client first. Vitest sets NODE_ENV only when it is
|
|
153
|
+
// unset, and production loads the React build that has no act().
|
|
154
|
+
updateJson(tree, `${projectRoot}/package.json`, (packageJson) => {
|
|
155
|
+
packageJson.nx = {
|
|
156
|
+
...packageJson.nx,
|
|
157
|
+
targets: {
|
|
158
|
+
...packageJson.nx?.targets,
|
|
159
|
+
test: {
|
|
160
|
+
dependsOn: ['^sdk'],
|
|
161
|
+
options: { env: { NODE_ENV: 'test' } },
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
return packageJson;
|
|
166
|
+
});
|
|
167
|
+
// The spec tsconfig of @nx/vitest has no JSX and no DOM lib, lists only the
|
|
168
|
+
// test files though the tests import the app, and lacks the jest-dom
|
|
169
|
+
// matcher types that setupFiles registers.
|
|
170
|
+
updateJson(tree, `${projectRoot}/tsconfig.spec.json`, (config) => {
|
|
171
|
+
config.compilerOptions = {
|
|
172
|
+
...config.compilerOptions,
|
|
173
|
+
jsx: 'react-jsx',
|
|
174
|
+
lib: ['ES2020', 'DOM', 'DOM.Iterable', 'DOM.AsyncIterable', 'ESNext'],
|
|
175
|
+
types: unique([
|
|
176
|
+
...(config.compilerOptions?.types ?? []).filter((type) => type !== 'vitest/globals'),
|
|
177
|
+
'@testing-library/jest-dom/vitest',
|
|
178
|
+
]),
|
|
179
|
+
};
|
|
180
|
+
config.include = unique([
|
|
181
|
+
...(config.include ?? []),
|
|
182
|
+
'src/**/*.ts',
|
|
183
|
+
'src/**/*.tsx',
|
|
184
|
+
]);
|
|
185
|
+
return config;
|
|
186
|
+
});
|
|
187
|
+
return task;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The nx.json keys of a React app: the Tailwind sync generator writes the
|
|
191
|
+
* `@source` lines of styles.css before a build, dev or serve, and the
|
|
192
|
+
* defaults of `nx g @nx/react:*`.
|
|
193
|
+
*/
|
|
194
|
+
function mergeReactNxJson(tree) {
|
|
195
|
+
updateJson(tree, 'nx.json', (nxJson) => {
|
|
196
|
+
nxJson.sync = {
|
|
197
|
+
...nxJson.sync,
|
|
198
|
+
generatorOptions: {
|
|
199
|
+
...nxJson.sync?.generatorOptions,
|
|
200
|
+
[tailwindSyncGenerator]: { additionalStylePaths: ['styles.css'] },
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
for (const target of ['build', 'dev', 'serve']) {
|
|
204
|
+
updateTargetDefault(nxJson, target, (entry) => ({
|
|
205
|
+
...entry,
|
|
206
|
+
syncGenerators: unique([
|
|
207
|
+
...(entry.syncGenerators ?? []),
|
|
208
|
+
tailwindSyncGenerator,
|
|
209
|
+
]),
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
nxJson.generators = mergeGeneratorDefaults(nxJson.generators, '@nx/react', {
|
|
213
|
+
application: {
|
|
214
|
+
style: 'css',
|
|
215
|
+
linter: 'eslint',
|
|
216
|
+
bundler: 'vite',
|
|
217
|
+
unitTestRunner: 'none',
|
|
218
|
+
e2eTestRunner: 'none',
|
|
219
|
+
routing: false,
|
|
220
|
+
},
|
|
221
|
+
component: { style: 'css' },
|
|
222
|
+
library: { style: 'css', linter: 'eslint', unitTestRunner: 'none' },
|
|
223
|
+
});
|
|
224
|
+
return nxJson;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Sorts the Tailwind classes with the formatter. It runs after formatFiles,
|
|
229
|
+
* because Prettier loads each plugin of .prettierrc and the install callback
|
|
230
|
+
* installs this one, so it formats .prettierrc itself, with no plugin.
|
|
231
|
+
*/
|
|
232
|
+
async function addTailwindPrettierPlugin(tree) {
|
|
233
|
+
if (!tree.exists('.prettierrc'))
|
|
234
|
+
return;
|
|
235
|
+
const config = readJson(tree, '.prettierrc');
|
|
236
|
+
config.plugins = unique([
|
|
237
|
+
...(config.plugins ?? []),
|
|
238
|
+
'prettier-plugin-tailwindcss',
|
|
239
|
+
]);
|
|
240
|
+
const { format } = await import('prettier');
|
|
241
|
+
tree.write('.prettierrc', await format(JSON.stringify(config), { parser: 'json' }));
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/react-app/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,MAAM,EACN,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,UAAU,EACV,MAAM,EACN,SAAS,EACT,OAAO,EACP,SAAS,EACT,UAAU,GACX,MAA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Ac,IAAI,EAAE,CAAC;oBAC/B,qBAAqB;iBACtB,CAAC;aACH,CAAC,CAAC,CAAC;QACN,CAAC;QACD,MAAM,CAAC,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE;YACzE,WAAW,EAAE;gBACX,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,QAAQ;gBAChB,OAAO,EAAE,MAAM;gBACf,cAAc,EAAE,MAAM;gBACtB,aAAa,EAAE,MAAM;gBACrB,OAAO,EAAE,KAAK;aACf;YACD,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;YAC3B,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE;SACpE,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,yBAAyB,CAAC,IAAU;IACjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;QAAE,OAAO;IACxC,MAAM,MAAM,GAAG,QAAQ,CAAyB,IAAI,EAAE,aAAa,CAAC,CAAC;IACrE,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QACzB,6BAA6B;KAC9B,CAAC,CAAC;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,CACR,aAAa,EACb,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CACzD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The root packages of a React project, for react-app and ui-package. The 4
|
|
3
|
+
* React lint plugins are the optional peers of @zukhruf/eslint that
|
|
4
|
+
* `@zukhruf/eslint/react` loads, and each project config loads that. Vite 8 is
|
|
5
|
+
* the peer of @rolldown/plugin-babel and @vitejs/plugin-react.
|
|
6
|
+
*/
|
|
7
|
+
export declare const reactRootPackages: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Packages that @nx/react and @nx/js add to the root and no project loads.
|
|
10
|
+
* The swc toolchain: Vite and esbuild bundle, and typescript-eslint parses.
|
|
11
|
+
* eslint-plugin-import, eslint-plugin-jsx-a11y and eslint-plugin-react: the
|
|
12
|
+
* `flat/react` config of @nx/react loads them, `@zukhruf/eslint/react` loads
|
|
13
|
+
* none of them, and each caps its ESLint peer below ESLint 10.
|
|
14
|
+
* eslint-plugin-react-hooks stays: `@zukhruf/eslint/react` loads it. React
|
|
15
|
+
* itself: each project declares the React that it imports.
|
|
16
|
+
*/
|
|
17
|
+
export declare const reactResidue: string[];
|
|
18
|
+
/**
|
|
19
|
+
* @juristr/nx-tailwind-sync depends on @nx/devkit 21.1.2, whose peer would
|
|
20
|
+
* install a second `nx`. The edge goes to the one Nx version (#4532).
|
|
21
|
+
*/
|
|
22
|
+
export declare const tailwindSyncOverrides: {
|
|
23
|
+
'@juristr/nx-tailwind-sync': {
|
|
24
|
+
'@nx/devkit': string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** The ESLint config of a React project: `@zukhruf/eslint/react`, the root config and `extra`. */
|
|
28
|
+
export declare function reactEslintConfig(rootOffset: string, extra: readonly string[]): string;
|
|
29
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/generators/react.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAcpD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,UASxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;CAEjC,CAAC;AAEF,kGAAkG;AAClG,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,CAeR"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { nxVersion, appPackageVersions as versions } from "./versions.js";
|
|
2
|
+
/**
|
|
3
|
+
* The root packages of a React project, for react-app and ui-package. The 4
|
|
4
|
+
* React lint plugins are the optional peers of @zukhruf/eslint that
|
|
5
|
+
* `@zukhruf/eslint/react` loads, and each project config loads that. Vite 8 is
|
|
6
|
+
* the peer of @rolldown/plugin-babel and @vitejs/plugin-react.
|
|
7
|
+
*/
|
|
8
|
+
export const reactRootPackages = {
|
|
9
|
+
'@eslint-react/eslint-plugin': versions['@eslint-react/eslint-plugin'],
|
|
10
|
+
'@rolldown/plugin-babel': versions['@rolldown/plugin-babel'],
|
|
11
|
+
'@tailwindcss/vite': versions['@tailwindcss/vite'],
|
|
12
|
+
'@types/react': versions['@types/react'],
|
|
13
|
+
'@types/react-dom': versions['@types/react-dom'],
|
|
14
|
+
'@vitejs/plugin-react': versions['@vitejs/plugin-react'],
|
|
15
|
+
'babel-plugin-react-compiler': versions['babel-plugin-react-compiler'],
|
|
16
|
+
'eslint-plugin-jsx-a11y-x': versions['eslint-plugin-jsx-a11y-x'],
|
|
17
|
+
'eslint-plugin-react-hooks': versions['eslint-plugin-react-hooks'],
|
|
18
|
+
'eslint-plugin-react-you-might-not-need-an-effect': versions['eslint-plugin-react-you-might-not-need-an-effect'],
|
|
19
|
+
tailwindcss: versions.tailwindcss,
|
|
20
|
+
vite: versions.vite,
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Packages that @nx/react and @nx/js add to the root and no project loads.
|
|
24
|
+
* The swc toolchain: Vite and esbuild bundle, and typescript-eslint parses.
|
|
25
|
+
* eslint-plugin-import, eslint-plugin-jsx-a11y and eslint-plugin-react: the
|
|
26
|
+
* `flat/react` config of @nx/react loads them, `@zukhruf/eslint/react` loads
|
|
27
|
+
* none of them, and each caps its ESLint peer below ESLint 10.
|
|
28
|
+
* eslint-plugin-react-hooks stays: `@zukhruf/eslint/react` loads it. React
|
|
29
|
+
* itself: each project declares the React that it imports.
|
|
30
|
+
*/
|
|
31
|
+
export const reactResidue = [
|
|
32
|
+
'react',
|
|
33
|
+
'react-dom',
|
|
34
|
+
'@swc/cli',
|
|
35
|
+
'@swc/core',
|
|
36
|
+
'@swc/helpers',
|
|
37
|
+
'eslint-plugin-import',
|
|
38
|
+
'eslint-plugin-jsx-a11y',
|
|
39
|
+
'eslint-plugin-react',
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* @juristr/nx-tailwind-sync depends on @nx/devkit 21.1.2, whose peer would
|
|
43
|
+
* install a second `nx`. The edge goes to the one Nx version (#4532).
|
|
44
|
+
*/
|
|
45
|
+
export const tailwindSyncOverrides = {
|
|
46
|
+
'@juristr/nx-tailwind-sync': { '@nx/devkit': nxVersion },
|
|
47
|
+
};
|
|
48
|
+
/** The ESLint config of a React project: `@zukhruf/eslint/react`, the root config and `extra`. */
|
|
49
|
+
export function reactEslintConfig(rootOffset, extra) {
|
|
50
|
+
const zukhrufImport = extra.length > 0 ? "import zukhruf from '@zukhruf/eslint';\n" : '';
|
|
51
|
+
const configs = extra
|
|
52
|
+
.map((name) => ` ...zukhruf.configs['${name}'],\n`)
|
|
53
|
+
.join('');
|
|
54
|
+
return `${zukhrufImport}import react from '@zukhruf/eslint/react';
|
|
55
|
+
|
|
56
|
+
import baseConfig from '${rootOffset}eslint.config.mjs';
|
|
57
|
+
|
|
58
|
+
export default [
|
|
59
|
+
...react,
|
|
60
|
+
...baseConfig,
|
|
61
|
+
${configs}];
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../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CAAC,IAAI,EAAE,EAAE,CAAC,yBAAyB,IAAI,OAAO,CAAC;SACnD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,GAAG,aAAa;;0BAEC,UAAU;;;;;EAKlC,OAAO;CACR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
/** The names in the root `dependencies` and `devDependencies`, before an Nx generator runs. */
|
|
3
|
+
export declare function rootDependencyNames(tree: Tree): Set<string>;
|
|
4
|
+
/**
|
|
5
|
+
* The install-script decision for fsevents, which vite brings to react-app and
|
|
6
|
+
* ui-package and @nx/jest brings to node-app. It ships prebuilt for macOS, so
|
|
7
|
+
* its script does not run, and strict-allow-scripts stops an install that has
|
|
8
|
+
* no decision for it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const fseventsScript: {
|
|
11
|
+
fsevents: boolean;
|
|
12
|
+
};
|
|
13
|
+
export interface RootDependencies {
|
|
14
|
+
/** The packages of the app. A package that was there before keeps its version. */
|
|
15
|
+
devDependencies: Record<string, string>;
|
|
16
|
+
/** Packages that the Nx generator adds and no project loads. They go when the run added them. */
|
|
17
|
+
residue?: readonly string[];
|
|
18
|
+
/** The install scripts of the packages that the generator adds. A decision that is there stays. */
|
|
19
|
+
allowScripts?: Record<string, boolean>;
|
|
20
|
+
/** Edges of `overrides`. An edge that is there stays. */
|
|
21
|
+
overrides?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Settles the root package.json after an Nx generator ran: each package of
|
|
25
|
+
* `devDependencies` that was not there before gets its version, also over the
|
|
26
|
+
* version that the Nx generator wrote; each name of `residue` that the run
|
|
27
|
+
* added goes; and `nx` and each `@nx/*` get `nxVersion` (#4532).
|
|
28
|
+
*/
|
|
29
|
+
export declare function settleRootDependencies(tree: Tree, before: Set<string>, settings: RootDependencies): void;
|
|
30
|
+
//# sourceMappingURL=root-dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-dependencies.d.ts","sourceRoot":"","sources":["../../src/generators/root-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAwB,MAAM,YAAY,CAAC;AAS7D,+FAA+F;AAC/F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAS3D;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;CAAsB,CAAC;AAElD,MAAM,WAAW,gBAAgB;IAC/B,kFAAkF;IAClF,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,iGAAiG;IACjG,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,mGAAmG;IACnG,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EACnB,QAAQ,EAAE,gBAAgB,GACzB,IAAI,CAuCN"}
|