@nx/remix 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/executors.json +14 -0
- package/generators.d.ts +14 -0
- package/generators.js +31 -0
- package/generators.json +90 -0
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/migrations.json +107 -0
- package/package.json +53 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/component-testing/index.d.ts +30 -0
- package/plugins/component-testing/index.js +64 -0
- package/src/executors/build/build.impl.d.ts +5 -0
- package/src/executors/build/build.impl.js +109 -0
- package/src/executors/build/schema.d.ts +7 -0
- package/src/executors/build/schema.json +38 -0
- package/src/executors/serve/schema.d.ts +9 -0
- package/src/executors/serve/schema.json +41 -0
- package/src/executors/serve/serve.impl.d.ts +6 -0
- package/src/executors/serve/serve.impl.js +77 -0
- package/src/generators/action/action.impl.d.ts +3 -0
- package/src/generators/action/action.impl.js +39 -0
- package/src/generators/action/schema.d.ts +10 -0
- package/src/generators/action/schema.json +29 -0
- package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1487 -0
- package/src/generators/application/application.impl.d.ts +5 -0
- package/src/generators/application/application.impl.js +198 -0
- package/src/generators/application/files/common/README.md__tmpl__ +54 -0
- package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
- package/src/generators/application/files/common/app/root.tsx__tmpl__ +32 -0
- package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
- package/src/generators/application/files/common/public/favicon.ico +0 -0
- package/src/generators/application/files/common/remix.config.js__tmpl__ +17 -0
- package/src/generators/application/files/common/remix.env.d.ts__tmpl__ +2 -0
- package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
- package/src/generators/application/files/common/tsconfig.app.json__tmpl__ +20 -0
- package/src/generators/application/files/common/tsconfig.json__tmpl__ +24 -0
- package/src/generators/application/files/integrated/.gitignore__tmpl__ +4 -0
- package/src/generators/application/files/integrated/package.json__tmpl__ +28 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +66 -0
- package/src/generators/application/lib/index.d.ts +3 -0
- package/src/generators/application/lib/index.js +6 -0
- package/src/generators/application/lib/normalize-options.d.ts +10 -0
- package/src/generators/application/lib/normalize-options.js +37 -0
- package/src/generators/application/lib/update-unit-test-config.d.ts +2 -0
- package/src/generators/application/lib/update-unit-test-config.js +55 -0
- package/src/generators/application/schema.d.ts +16 -0
- package/src/generators/application/schema.json +68 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +5 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +34 -0
- package/src/generators/cypress-component-configuration/files/cypress.config.ts__tmpl__ +6 -0
- package/src/generators/cypress-component-configuration/schema.d.ts +6 -0
- package/src/generators/cypress-component-configuration/schema.json +41 -0
- package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +61 -0
- package/src/generators/error-boundary/error-boundary.impl.d.ts +3 -0
- package/src/generators/error-boundary/error-boundary.impl.js +12 -0
- package/src/generators/error-boundary/lib/add-v2-error-boundary.d.ts +3 -0
- package/src/generators/error-boundary/lib/add-v2-error-boundary.js +38 -0
- package/src/generators/error-boundary/lib/index.d.ts +2 -0
- package/src/generators/error-boundary/lib/index.js +5 -0
- package/src/generators/error-boundary/lib/normalize-options.d.ts +3 -0
- package/src/generators/error-boundary/lib/normalize-options.js +17 -0
- package/src/generators/error-boundary/schema.d.ts +11 -0
- package/src/generators/error-boundary/schema.json +37 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +60 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +33 -0
- package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
- package/src/generators/library/lib/add-tsconfig-entry-points.d.ts +3 -0
- package/src/generators/library/lib/add-tsconfig-entry-points.js +19 -0
- package/src/generators/library/lib/add-unit-testing.d.ts +3 -0
- package/src/generators/library/lib/add-unit-testing.js +32 -0
- package/src/generators/library/lib/index.d.ts +4 -0
- package/src/generators/library/lib/index.js +7 -0
- package/src/generators/library/lib/normalize-options.d.ts +7 -0
- package/src/generators/library/lib/normalize-options.js +29 -0
- package/src/generators/library/lib/update-buildable-config.d.ts +2 -0
- package/src/generators/library/lib/update-buildable-config.js +21 -0
- package/src/generators/library/library.impl.d.ts +6 -0
- package/src/generators/library/library.impl.js +45 -0
- package/src/generators/library/schema.d.ts +16 -0
- package/src/generators/library/schema.json +74 -0
- package/src/generators/loader/loader.impl.d.ts +3 -0
- package/src/generators/loader/loader.impl.js +39 -0
- package/src/generators/loader/schema.d.ts +10 -0
- package/src/generators/loader/schema.json +29 -0
- package/src/generators/meta/lib/v2.impl.d.ts +3 -0
- package/src/generators/meta/lib/v2.impl.js +28 -0
- package/src/generators/meta/meta.impl.d.ts +3 -0
- package/src/generators/meta/meta.impl.js +7 -0
- package/src/generators/meta/schema.d.ts +10 -0
- package/src/generators/meta/schema.json +29 -0
- package/src/generators/preset/lib/normalize-options.d.ts +11 -0
- package/src/generators/preset/lib/normalize-options.js +20 -0
- package/src/generators/preset/preset.impl.d.ts +3 -0
- package/src/generators/preset/preset.impl.js +32 -0
- package/src/generators/preset/schema.d.ts +4 -0
- package/src/generators/preset/schema.json +14 -0
- package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
- package/src/generators/resource-route/resource-route.impl.d.ts +3 -0
- package/src/generators/resource-route/resource-route.impl.js +41 -0
- package/src/generators/resource-route/schema.d.ts +13 -0
- package/src/generators/resource-route/schema.json +51 -0
- package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +95 -0
- package/src/generators/route/route.impl.d.ts +3 -0
- package/src/generators/route/route.impl.js +78 -0
- package/src/generators/route/schema.d.ts +15 -0
- package/src/generators/route/schema.json +62 -0
- package/src/generators/setup/schema.json +14 -0
- package/src/generators/setup/setup.impl.d.ts +2 -0
- package/src/generators/setup/setup.impl.js +34 -0
- package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +170 -0
- package/src/generators/setup-tailwind/files/app/tailwind.css__tpl__ +3 -0
- package/src/generators/setup-tailwind/files/tailwind.config.ts__tpl__ +13 -0
- package/src/generators/setup-tailwind/lib/index.d.ts +1 -0
- package/src/generators/setup-tailwind/lib/index.js +4 -0
- package/src/generators/setup-tailwind/lib/update-remix-config.d.ts +2 -0
- package/src/generators/setup-tailwind/lib/update-remix-config.js +35 -0
- package/src/generators/setup-tailwind/schema.d.ts +5 -0
- package/src/generators/setup-tailwind/schema.json +36 -0
- package/src/generators/setup-tailwind/setup-tailwind.impl.d.ts +3 -0
- package/src/generators/setup-tailwind/setup-tailwind.impl.js +34 -0
- package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +73 -0
- package/src/generators/storybook-configuration/files/vite.config.ts__tpl__ +15 -0
- package/src/generators/storybook-configuration/schema.d.ts +16 -0
- package/src/generators/storybook-configuration/schema.json +89 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +4 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.js +26 -0
- package/src/generators/style/schema.d.ts +10 -0
- package/src/generators/style/schema.json +36 -0
- package/src/generators/style/style.impl.d.ts +3 -0
- package/src/generators/style/style.impl.js +61 -0
- package/src/generators/utils/update-dependencies.d.ts +2 -0
- package/src/generators/utils/update-dependencies.js +21 -0
- package/src/plugins/__snapshots__/plugin.spec.ts.snap +113 -0
- package/src/plugins/plugin.d.ts +9 -0
- package/src/plugins/plugin.js +136 -0
- package/src/utils/create-watch-paths.d.ts +8 -0
- package/src/utils/create-watch-paths.js +40 -0
- package/src/utils/get-default-export-name.d.ts +2 -0
- package/src/utils/get-default-export-name.js +8 -0
- package/src/utils/get-default-export.d.ts +2 -0
- package/src/utils/get-default-export.js +15 -0
- package/src/utils/insert-import.d.ts +4 -0
- package/src/utils/insert-import.js +54 -0
- package/src/utils/insert-statement-after-imports.d.ts +5 -0
- package/src/utils/insert-statement-after-imports.js +28 -0
- package/src/utils/insert-statement-in-default-function.d.ts +2 -0
- package/src/utils/insert-statement-in-default-function.js +23 -0
- package/src/utils/remix-config.d.ts +5 -0
- package/src/utils/remix-config.js +45 -0
- package/src/utils/remix-route-utils.d.ts +13 -0
- package/src/utils/remix-route-utils.js +70 -0
- package/src/utils/testing-config-utils.d.ts +4 -0
- package/src/utils/testing-config-utils.js +79 -0
- package/src/utils/upsert-links-function.d.ts +2 -0
- package/src/utils/upsert-links-function.js +31 -0
- package/src/utils/versions.d.ts +16 -0
- package/src/utils/versions.js +28 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertImport = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const typescript_1 = require("typescript");
|
|
6
|
+
const insert_statement_after_imports_1 = require("./insert-statement-after-imports");
|
|
7
|
+
function insertImport(tree, path, name, modulePath, options = { typeOnly: false }) {
|
|
8
|
+
if (!tree.exists(path))
|
|
9
|
+
throw Error(`Could not insert import ${name} from ${modulePath} in ${path}: path not found`);
|
|
10
|
+
const contents = tree.read(path, 'utf-8');
|
|
11
|
+
const sourceFile = (0, typescript_1.createSourceFile)(path, contents, typescript_1.ScriptTarget.ESNext);
|
|
12
|
+
let importStatements = sourceFile.statements.filter(typescript_1.isImportDeclaration);
|
|
13
|
+
if (options.typeOnly) {
|
|
14
|
+
importStatements = importStatements.filter((node) => node.importClause.isTypeOnly);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
importStatements = importStatements.filter((node) => !node.importClause.isTypeOnly);
|
|
18
|
+
}
|
|
19
|
+
const existingImport = importStatements.find((statement) => (0, typescript_1.isStringLiteral)(statement.moduleSpecifier) &&
|
|
20
|
+
statement.moduleSpecifier
|
|
21
|
+
.getText(sourceFile)
|
|
22
|
+
.replace(/['"`]/g, '')
|
|
23
|
+
.trim() === modulePath &&
|
|
24
|
+
statement.importClause.namedBindings &&
|
|
25
|
+
(0, typescript_1.isNamedImports)(statement.importClause.namedBindings));
|
|
26
|
+
if (!existingImport) {
|
|
27
|
+
(0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, path, options.typeOnly
|
|
28
|
+
? `import type { ${name} } from '${modulePath}';`
|
|
29
|
+
: `import { ${name} } from '${modulePath}';`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const namedImports = existingImport.importClause
|
|
33
|
+
.namedBindings;
|
|
34
|
+
const alreadyImported = namedImports.elements.find((element) => element.name.escapedText === name) !== undefined;
|
|
35
|
+
if (!alreadyImported) {
|
|
36
|
+
const index = namedImports.getEnd() - 1;
|
|
37
|
+
let text;
|
|
38
|
+
if (namedImports.elements.hasTrailingComma) {
|
|
39
|
+
text = `${name},`;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
text = `,${name}`;
|
|
43
|
+
}
|
|
44
|
+
const newContents = (0, devkit_1.applyChangesToString)(contents, [
|
|
45
|
+
{
|
|
46
|
+
type: devkit_1.ChangeType.Insert,
|
|
47
|
+
index,
|
|
48
|
+
text,
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
tree.write(path, newContents);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.insertImport = insertImport;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertStatementAfterImports = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const typescript_1 = require("typescript");
|
|
6
|
+
/**
|
|
7
|
+
* Insert a statement after the last import statement in a file
|
|
8
|
+
*/
|
|
9
|
+
function insertStatementAfterImports(tree, path, statement) {
|
|
10
|
+
const contents = tree.read(path, 'utf-8');
|
|
11
|
+
const sourceFile = (0, typescript_1.createSourceFile)(path, contents, typescript_1.ScriptTarget.ESNext);
|
|
12
|
+
const importStatements = sourceFile.statements.filter(typescript_1.isImportDeclaration);
|
|
13
|
+
const index = importStatements.length > 0
|
|
14
|
+
? importStatements[importStatements.length - 1].getEnd()
|
|
15
|
+
: 0;
|
|
16
|
+
if (importStatements.length > 0) {
|
|
17
|
+
statement = `\n${statement}`;
|
|
18
|
+
}
|
|
19
|
+
const newContents = (0, devkit_1.applyChangesToString)(contents, [
|
|
20
|
+
{
|
|
21
|
+
type: devkit_1.ChangeType.Insert,
|
|
22
|
+
index,
|
|
23
|
+
text: statement,
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
tree.write(path, newContents);
|
|
27
|
+
}
|
|
28
|
+
exports.insertStatementAfterImports = insertStatementAfterImports;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertStatementInDefaultFunction = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const get_default_export_1 = require("./get-default-export");
|
|
6
|
+
function insertStatementInDefaultFunction(tree, path, statement) {
|
|
7
|
+
const defaultExport = (0, get_default_export_1.getDefaultExport)(tree, path);
|
|
8
|
+
if (!defaultExport) {
|
|
9
|
+
throw Error('No default export found!');
|
|
10
|
+
}
|
|
11
|
+
const index = defaultExport.body.statements.length > 0
|
|
12
|
+
? defaultExport.body.statements[0].pos
|
|
13
|
+
: 0;
|
|
14
|
+
const newContents = (0, devkit_1.applyChangesToString)(tree.read(path, 'utf-8'), [
|
|
15
|
+
{
|
|
16
|
+
type: devkit_1.ChangeType.Insert,
|
|
17
|
+
index,
|
|
18
|
+
text: statement,
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
tree.write(path, newContents);
|
|
22
|
+
}
|
|
23
|
+
exports.insertStatementInDefaultFunction = insertStatementInDefaultFunction;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import type { AppConfig } from '@remix-run/dev';
|
|
3
|
+
export declare function getRemixConfigPath(tree: Tree, projectName: string): string;
|
|
4
|
+
export declare function getRemixConfigPathFromProjectRoot(tree: Tree, projectRoot: string): string;
|
|
5
|
+
export declare function getRemixConfigValues(tree: Tree, projectName: string): Promise<AppConfig>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRemixConfigValues = exports.getRemixConfigPathFromProjectRoot = exports.getRemixConfigPath = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function getRemixConfigPath(tree, projectName) {
|
|
6
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
7
|
+
if (!project)
|
|
8
|
+
throw new Error(`Project does not exist: ${projectName}`);
|
|
9
|
+
for (const ext of ['.mjs', '.cjs', '.js']) {
|
|
10
|
+
const configPath = (0, devkit_1.joinPathFragments)(project.root, `remix.config${ext}`);
|
|
11
|
+
if (tree.exists(configPath)) {
|
|
12
|
+
return configPath;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.getRemixConfigPath = getRemixConfigPath;
|
|
17
|
+
function getRemixConfigPathFromProjectRoot(tree, projectRoot) {
|
|
18
|
+
let pathToRemixConfig;
|
|
19
|
+
for (const ext of ['.js', '.mjs', '.cjs']) {
|
|
20
|
+
pathToRemixConfig = (0, devkit_1.joinPathFragments)(projectRoot, `remix.config${ext}`);
|
|
21
|
+
if (tree.exists(pathToRemixConfig)) {
|
|
22
|
+
return pathToRemixConfig;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Could not find a Remix Config File. Please ensure a "remix.config.js" file exists at the root of your project.`);
|
|
26
|
+
}
|
|
27
|
+
exports.getRemixConfigPathFromProjectRoot = getRemixConfigPathFromProjectRoot;
|
|
28
|
+
const _remixConfigCache = {};
|
|
29
|
+
async function getRemixConfigValues(tree, projectName) {
|
|
30
|
+
const remixConfigPath = (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, getRemixConfigPath(tree, projectName));
|
|
31
|
+
const cacheKey = `${projectName}/${remixConfigPath}`;
|
|
32
|
+
let appConfig = _remixConfigCache[cacheKey];
|
|
33
|
+
if (!appConfig) {
|
|
34
|
+
try {
|
|
35
|
+
const importedConfig = await Function(`return import("${remixConfigPath}?t=${Date.now()}")`)();
|
|
36
|
+
appConfig = (importedConfig?.default || importedConfig);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
appConfig = require(remixConfigPath);
|
|
40
|
+
}
|
|
41
|
+
_remixConfigCache[cacheKey] = appConfig;
|
|
42
|
+
}
|
|
43
|
+
return appConfig;
|
|
44
|
+
}
|
|
45
|
+
exports.getRemixConfigValues = getRemixConfigValues;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param tree
|
|
5
|
+
* @param path to the route which could be fully specified or just "foo/bar"
|
|
6
|
+
* @param projectName the name of the project where the route should be added
|
|
7
|
+
* @param fileExtension the file extension to add to resolved route file
|
|
8
|
+
* @returns file path to the route
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveRemixRouteFile(tree: Tree, path: string, projectName?: string, fileExtension?: string): Promise<string>;
|
|
11
|
+
export declare function normalizeRoutePath(path: string): string;
|
|
12
|
+
export declare function checkRoutePathForErrors(path: string): RegExpMatchArray;
|
|
13
|
+
export declare function resolveRemixAppDirectory(tree: Tree, projectName: string): Promise<string>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveRemixAppDirectory = exports.checkRoutePathForErrors = exports.normalizeRoutePath = exports.resolveRemixRouteFile = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const remix_config_1 = require("./remix-config");
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param tree
|
|
9
|
+
* @param path to the route which could be fully specified or just "foo/bar"
|
|
10
|
+
* @param projectName the name of the project where the route should be added
|
|
11
|
+
* @param fileExtension the file extension to add to resolved route file
|
|
12
|
+
* @returns file path to the route
|
|
13
|
+
*/
|
|
14
|
+
async function resolveRemixRouteFile(tree, path, projectName, fileExtension) {
|
|
15
|
+
const { name: routePath } = (0, devkit_1.names)(path.replace(/^\//, '').replace(/\/$/, ''));
|
|
16
|
+
if (!projectName) {
|
|
17
|
+
return appendRouteFileExtension(tree, routePath, fileExtension);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
21
|
+
if (!project)
|
|
22
|
+
throw new Error(`Project does not exist: ${projectName}`);
|
|
23
|
+
const normalizedRoutePath = normalizeRoutePath(routePath);
|
|
24
|
+
const fileName = appendRouteFileExtension(tree, normalizedRoutePath, fileExtension);
|
|
25
|
+
return (0, devkit_1.joinPathFragments)(await resolveRemixAppDirectory(tree, projectName), 'routes', fileName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.resolveRemixRouteFile = resolveRemixRouteFile;
|
|
29
|
+
function appendRouteFileExtension(tree, routePath, fileExtension) {
|
|
30
|
+
// if no file extension specified, let's try to find it
|
|
31
|
+
if (!fileExtension) {
|
|
32
|
+
// see if the path already has it
|
|
33
|
+
const extensionMatch = routePath.match(/(\.[^.]+)$/);
|
|
34
|
+
if (extensionMatch) {
|
|
35
|
+
fileExtension = extensionMatch[0];
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// look for either .ts or .tsx to exist in tree
|
|
39
|
+
if (tree.exists(`${routePath}.ts`)) {
|
|
40
|
+
fileExtension = '.ts';
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// default to .tsx if nothing else found
|
|
44
|
+
fileExtension = '.tsx';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return routePath.endsWith(fileExtension)
|
|
49
|
+
? routePath
|
|
50
|
+
: `${routePath}${fileExtension}`;
|
|
51
|
+
}
|
|
52
|
+
function normalizeRoutePath(path) {
|
|
53
|
+
return path.indexOf('/routes/') > -1
|
|
54
|
+
? path.substring(path.indexOf('/routes/') + 8)
|
|
55
|
+
: path;
|
|
56
|
+
}
|
|
57
|
+
exports.normalizeRoutePath = normalizeRoutePath;
|
|
58
|
+
function checkRoutePathForErrors(path) {
|
|
59
|
+
return (path.match(/\w\.\.\w/) || // route.$withParams.tsx => route..tsx
|
|
60
|
+
path.match(/\w\/\/\w/) || // route/$withParams/index.tsx => route//index.tsx
|
|
61
|
+
path.match(/\w\/\.\w/) // route/$withParams.tsx => route/.tsx
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
exports.checkRoutePathForErrors = checkRoutePathForErrors;
|
|
65
|
+
async function resolveRemixAppDirectory(tree, projectName) {
|
|
66
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
67
|
+
const remixConfig = await (0, remix_config_1.getRemixConfigValues)(tree, projectName);
|
|
68
|
+
return (0, devkit_1.joinPathFragments)(project.root, remixConfig.appDirectory ?? 'app');
|
|
69
|
+
}
|
|
70
|
+
exports.resolveRemixAppDirectory = resolveRemixAppDirectory;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export declare function updateVitestTestSetup(tree: Tree, pathToVitestConfig: string, pathToTestSetup: string): void;
|
|
3
|
+
export declare function updateJestTestSetup(tree: Tree, pathToJestConfig: string, pathToTestSetup: string): void;
|
|
4
|
+
export declare function updateVitestTestIncludes(tree: Tree, pathToVitestConfig: string, includesString: string): void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateVitestTestIncludes = exports.updateJestTestSetup = exports.updateVitestTestSetup = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
6
|
+
let tsModule;
|
|
7
|
+
function updateVitestTestSetup(tree, pathToVitestConfig, pathToTestSetup) {
|
|
8
|
+
if (!tsModule) {
|
|
9
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
10
|
+
}
|
|
11
|
+
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
12
|
+
const fileContents = tree.read(pathToVitestConfig, 'utf-8');
|
|
13
|
+
const ast = tsquery.ast(fileContents);
|
|
14
|
+
const TEST_SETUPFILES_SELECTOR = 'PropertyAssignment:has(Identifier[name=test]) PropertyAssignment:has(Identifier[name=setupFiles])';
|
|
15
|
+
const nodes = tsquery(ast, TEST_SETUPFILES_SELECTOR, {
|
|
16
|
+
visitAllChildren: true,
|
|
17
|
+
});
|
|
18
|
+
let updatedFileContents = fileContents;
|
|
19
|
+
if (nodes.length === 0) {
|
|
20
|
+
const TEST_CONFIG_SELECTOR = 'PropertyAssignment:has(Identifier[name=test]) > ObjectLiteralExpression';
|
|
21
|
+
const testConfigNodes = tsquery(ast, TEST_CONFIG_SELECTOR, {
|
|
22
|
+
visitAllChildren: true,
|
|
23
|
+
});
|
|
24
|
+
updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, testConfigNodes[0].getStart() + 1)}setupFiles: ['${pathToTestSetup}'],${fileContents.slice(testConfigNodes[0].getStart() + 1)}`;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const arrayNodes = tsquery(nodes[0], 'ArrayLiteralExpression', {
|
|
28
|
+
visitAllChildren: true,
|
|
29
|
+
});
|
|
30
|
+
if (arrayNodes.length !== 0) {
|
|
31
|
+
updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, arrayNodes[0].getStart() + 1)}'${pathToTestSetup}',${fileContents.slice(arrayNodes[0].getStart() + 1)}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
tree.write(pathToVitestConfig, updatedFileContents);
|
|
35
|
+
}
|
|
36
|
+
exports.updateVitestTestSetup = updateVitestTestSetup;
|
|
37
|
+
function updateJestTestSetup(tree, pathToJestConfig, pathToTestSetup) {
|
|
38
|
+
if (!tsModule) {
|
|
39
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
40
|
+
}
|
|
41
|
+
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
42
|
+
const fileContents = tree.read(pathToJestConfig, 'utf-8');
|
|
43
|
+
const ast = tsquery.ast(fileContents);
|
|
44
|
+
const TEST_SETUPFILES_SELECTOR = 'PropertyAssignment:has(Identifier[name=setupFilesAfterEnv])';
|
|
45
|
+
const nodes = tsquery(ast, TEST_SETUPFILES_SELECTOR, {
|
|
46
|
+
visitAllChildren: true,
|
|
47
|
+
});
|
|
48
|
+
if (nodes.length === 0) {
|
|
49
|
+
const CONFIG_SELECTOR = 'ObjectLiteralExpression';
|
|
50
|
+
const nodes = tsquery(ast, CONFIG_SELECTOR, { visitAllChildren: true });
|
|
51
|
+
const updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, nodes[0].getStart() + 1)}setupFilesAfterEnv: ['${pathToTestSetup}'],${fileContents.slice(nodes[0].getStart() + 1)}`;
|
|
52
|
+
tree.write(pathToJestConfig, updatedFileContents);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const arrayNodes = tsquery(nodes[0], 'ArrayLiteralExpression', {
|
|
56
|
+
visitAllChildren: true,
|
|
57
|
+
});
|
|
58
|
+
if (arrayNodes.length !== 0) {
|
|
59
|
+
const updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, arrayNodes[0].getStart() + 1)}'${pathToTestSetup}',${fileContents.slice(arrayNodes[0].getStart() + 1)}`;
|
|
60
|
+
tree.write(pathToJestConfig, updatedFileContents);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.updateJestTestSetup = updateJestTestSetup;
|
|
65
|
+
function updateVitestTestIncludes(tree, pathToVitestConfig, includesString) {
|
|
66
|
+
if (!tsModule) {
|
|
67
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
68
|
+
}
|
|
69
|
+
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
70
|
+
const fileContents = tree.read(pathToVitestConfig, 'utf-8');
|
|
71
|
+
const ast = tsquery.ast(fileContents);
|
|
72
|
+
const TEST_INCLUDE_SELECTOR = 'PropertyAssignment:has(Identifier[name=test]) PropertyAssignment:has(Identifier[name=include])';
|
|
73
|
+
const nodes = tsquery(ast, TEST_INCLUDE_SELECTOR, { visitAllChildren: true });
|
|
74
|
+
if (nodes.length !== 0) {
|
|
75
|
+
const updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, nodes[0].getStart())}include: ["${includesString}"]${fileContents.slice(nodes[0].getEnd())}`;
|
|
76
|
+
tree.write(pathToVitestConfig, updatedFileContents);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.updateVitestTestIncludes = updateVitestTestIncludes;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upsertLinksFunction = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const insert_import_1 = require("./insert-import");
|
|
7
|
+
const insert_statement_after_imports_1 = require("./insert-statement-after-imports");
|
|
8
|
+
function upsertLinksFunction(tree, filePath, importName, importPath, linkObject) {
|
|
9
|
+
(0, insert_import_1.insertImport)(tree, filePath, 'LinksFunction', '@remix-run/node', {
|
|
10
|
+
typeOnly: true,
|
|
11
|
+
});
|
|
12
|
+
(0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, filePath, (0, devkit_1.stripIndents) `import ${importName} from "${importPath}";`);
|
|
13
|
+
const fileContents = tree.read(filePath, 'utf-8');
|
|
14
|
+
const LINKS_FUNCTION_SELECTOR = 'VariableDeclaration:has(TypeReference > Identifier[name=LinksFunction])';
|
|
15
|
+
const ast = tsquery_1.tsquery.ast(fileContents);
|
|
16
|
+
const linksFunctionNodes = (0, tsquery_1.tsquery)(ast, LINKS_FUNCTION_SELECTOR, {
|
|
17
|
+
visitAllChildren: true,
|
|
18
|
+
});
|
|
19
|
+
if (linksFunctionNodes.length === 0) {
|
|
20
|
+
(0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, filePath, (0, devkit_1.stripIndents) `export const links: LinksFunction = () => [
|
|
21
|
+
${linkObject},
|
|
22
|
+
];`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const linksArrayNodes = (0, tsquery_1.tsquery)(linksFunctionNodes[0], 'ArrayLiteralExpression', { visitAllChildren: true });
|
|
26
|
+
const arrayNode = linksArrayNodes[0];
|
|
27
|
+
const updatedFileContents = `${fileContents.slice(0, arrayNode.getStart() + 1)}\n${linkObject},${fileContents.slice(arrayNode.getStart() + 1)}`;
|
|
28
|
+
tree.write(filePath, updatedFileContents);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.upsertLinksFunction = upsertLinksFunction;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
export declare const nxVersion: any;
|
|
3
|
+
export declare const remixVersion = "^2.6.0";
|
|
4
|
+
export declare const isbotVersion = "^4.4.0";
|
|
5
|
+
export declare const reactVersion = "^18.2.0";
|
|
6
|
+
export declare const reactDomVersion = "^18.2.0";
|
|
7
|
+
export declare const typesReactVersion = "^18.2.0";
|
|
8
|
+
export declare const typesReactDomVersion = "^18.2.0";
|
|
9
|
+
export declare const eslintVersion = "^8.56.0";
|
|
10
|
+
export declare const typescriptVersion = "^5.3.3";
|
|
11
|
+
export declare const tailwindVersion = "^3.3.0";
|
|
12
|
+
export declare const testingLibraryReactVersion = "^14.1.2";
|
|
13
|
+
export declare const testingLibraryJestDomVersion = "^6.2.0";
|
|
14
|
+
export declare const testingLibraryUserEventsVersion = "^14.5.2";
|
|
15
|
+
export declare function getRemixVersion(tree: Tree): string;
|
|
16
|
+
export declare function getPackageVersion(tree: Tree, packageName: string): any;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPackageVersion = exports.getRemixVersion = exports.testingLibraryUserEventsVersion = exports.testingLibraryJestDomVersion = exports.testingLibraryReactVersion = exports.tailwindVersion = exports.typescriptVersion = exports.eslintVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.reactDomVersion = exports.reactVersion = exports.isbotVersion = exports.remixVersion = exports.nxVersion = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
exports.nxVersion = require('../../package.json').version;
|
|
6
|
+
exports.remixVersion = '^2.6.0';
|
|
7
|
+
exports.isbotVersion = '^4.4.0';
|
|
8
|
+
exports.reactVersion = '^18.2.0';
|
|
9
|
+
exports.reactDomVersion = '^18.2.0';
|
|
10
|
+
exports.typesReactVersion = '^18.2.0';
|
|
11
|
+
exports.typesReactDomVersion = '^18.2.0';
|
|
12
|
+
exports.eslintVersion = '^8.56.0';
|
|
13
|
+
exports.typescriptVersion = '^5.3.3';
|
|
14
|
+
exports.tailwindVersion = '^3.3.0';
|
|
15
|
+
exports.testingLibraryReactVersion = '^14.1.2';
|
|
16
|
+
exports.testingLibraryJestDomVersion = '^6.2.0';
|
|
17
|
+
exports.testingLibraryUserEventsVersion = '^14.5.2';
|
|
18
|
+
function getRemixVersion(tree) {
|
|
19
|
+
return getPackageVersion(tree, '@remix-run/dev') ?? exports.remixVersion;
|
|
20
|
+
}
|
|
21
|
+
exports.getRemixVersion = getRemixVersion;
|
|
22
|
+
function getPackageVersion(tree, packageName) {
|
|
23
|
+
const packageJsonContents = (0, devkit_1.readJson)(tree, 'package.json');
|
|
24
|
+
return (packageJsonContents?.['devDependencies']?.[packageName] ??
|
|
25
|
+
packageJsonContents?.['dependencies']?.[packageName] ??
|
|
26
|
+
null);
|
|
27
|
+
}
|
|
28
|
+
exports.getPackageVersion = getPackageVersion;
|