@aws/nx-plugin 0.1.0 → 0.1.2

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.
Files changed (88) hide show
  1. package/LICENSE +175 -0
  2. package/LICENSE-THIRD-PARTY +37594 -0
  3. package/NOTICE +2 -0
  4. package/package.json +11 -10
  5. package/src/cloudscape-website/app/generator.d.ts +4 -0
  6. package/src/cloudscape-website/app/generator.js +139 -170
  7. package/src/cloudscape-website/app/generator.js.map +1 -1
  8. package/src/cloudscape-website/app/schema.d.ts +4 -0
  9. package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +0 -4
  10. package/src/cloudscape-website/cognito-auth/generator.d.ts +4 -0
  11. package/src/cloudscape-website/cognito-auth/generator.js +82 -93
  12. package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
  13. package/src/cloudscape-website/cognito-auth/schema.d.ts +4 -0
  14. package/src/cloudscape-website/runtime-config/generator.d.ts +4 -0
  15. package/src/cloudscape-website/runtime-config/generator.js +56 -70
  16. package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
  17. package/src/cloudscape-website/runtime-config/schema.d.ts +4 -0
  18. package/src/gitlab/generator.d.ts +4 -0
  19. package/src/gitlab/generator.js +13 -22
  20. package/src/gitlab/generator.js.map +1 -1
  21. package/src/gitlab/schema.d.ts +4 -0
  22. package/src/index.d.ts +4 -0
  23. package/src/index.js +4 -2
  24. package/src/index.js.map +1 -1
  25. package/src/infra/app/__snapshots__/generator.spec.ts.snap +6 -6
  26. package/src/infra/app/generator.d.ts +4 -0
  27. package/src/infra/app/generator.js +57 -71
  28. package/src/infra/app/generator.js.map +1 -1
  29. package/src/infra/app/schema.d.ts +4 -0
  30. package/src/trpc/backend/generator.d.ts +4 -0
  31. package/src/trpc/backend/generator.js +95 -116
  32. package/src/trpc/backend/generator.js.map +1 -1
  33. package/src/trpc/backend/schema.d.ts +4 -1
  34. package/src/trpc/react/generator.d.ts +4 -0
  35. package/src/trpc/react/generator.js +62 -76
  36. package/src/trpc/react/generator.js.map +1 -1
  37. package/src/trpc/react/schema.d.ts +4 -0
  38. package/src/ts/cjs-to-esm/generator.d.ts +4 -0
  39. package/src/ts/cjs-to-esm/generator.js +131 -143
  40. package/src/ts/cjs-to-esm/generator.js.map +1 -1
  41. package/src/ts/cjs-to-esm/schema.d.ts +4 -0
  42. package/src/ts/lib/eslint.d.ts +6 -2
  43. package/src/ts/lib/eslint.js +20 -28
  44. package/src/ts/lib/eslint.js.map +1 -1
  45. package/src/ts/lib/generator.d.ts +6 -2
  46. package/src/ts/lib/generator.js +35 -51
  47. package/src/ts/lib/generator.js.map +1 -1
  48. package/src/ts/lib/schema.d.ts +6 -2
  49. package/src/ts/lib/ts-project-utils.d.ts +6 -2
  50. package/src/ts/lib/ts-project-utils.js +53 -83
  51. package/src/ts/lib/ts-project-utils.js.map +1 -1
  52. package/src/ts/lib/types.d.ts +4 -0
  53. package/src/ts/lib/types.js +1 -4
  54. package/src/ts/lib/types.js.map +1 -1
  55. package/src/ts/lib/vitest.d.ts +6 -2
  56. package/src/ts/lib/vitest.js +49 -51
  57. package/src/ts/lib/vitest.js.map +1 -1
  58. package/src/utils/npm-scope.d.ts +4 -0
  59. package/src/utils/npm-scope.js +19 -27
  60. package/src/utils/npm-scope.js.map +1 -1
  61. package/src/utils/paths.d.ts +5 -1
  62. package/src/utils/paths.js +13 -23
  63. package/src/utils/paths.js.map +1 -1
  64. package/src/utils/shared-constructs.d.ts +4 -0
  65. package/src/utils/shared-constructs.js +44 -68
  66. package/src/utils/shared-constructs.js.map +1 -1
  67. package/src/utils/versions.d.ts +23 -18
  68. package/src/utils/versions.js +35 -45
  69. package/src/utils/versions.js.map +1 -1
  70. package/src/cloudscape-website/app/schema.d.js +0 -6
  71. package/src/cloudscape-website/app/schema.d.js.map +0 -1
  72. package/src/cloudscape-website/cognito-auth/schema.d.js +0 -6
  73. package/src/cloudscape-website/cognito-auth/schema.d.js.map +0 -1
  74. package/src/cloudscape-website/runtime-config/schema.d.js +0 -6
  75. package/src/cloudscape-website/runtime-config/schema.d.js.map +0 -1
  76. package/src/gitlab/files/.gitlab-ci.yml.template +0 -26
  77. package/src/gitlab/schema.d.js +0 -6
  78. package/src/gitlab/schema.d.js.map +0 -1
  79. package/src/infra/app/schema.d.js +0 -6
  80. package/src/infra/app/schema.d.js.map +0 -1
  81. package/src/trpc/backend/schema.d.js +0 -6
  82. package/src/trpc/backend/schema.d.js.map +0 -1
  83. package/src/trpc/react/schema.d.js +0 -6
  84. package/src/trpc/react/schema.d.js.map +0 -1
  85. package/src/ts/cjs-to-esm/schema.d.js +0 -6
  86. package/src/ts/cjs-to-esm/schema.d.js.map +0 -1
  87. package/src/ts/lib/schema.d.js +0 -6
  88. package/src/ts/lib/schema.d.js.map +0 -1
@@ -1,41 +1,33 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "configureEslint", {
6
- enumerable: true,
7
- get: function() {
8
- return configureEslint;
9
- }
10
- });
11
- const _extends = require("@swc/helpers/_/_extends");
12
- const _devkit = require("@nx/devkit");
13
- const configureEslint = (tree, options)=>{
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureEslint = void 0;
4
+ /**
5
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ const devkit_1 = require("@nx/devkit");
9
+ const configureEslint = (tree, options) => {
10
+ var _a;
14
11
  // Configure the lint task
15
- const projectConfiguration = (0, _devkit.readProjectConfiguration)(tree, options.fullyQualifiedName);
12
+ const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.fullyQualifiedName);
16
13
  if (!projectConfiguration.targets.lint) {
17
14
  projectConfiguration.targets.lint = {
18
- executor: "@nx/eslint:lint",
15
+ executor: '@nx/eslint:lint',
19
16
  options: {
20
- fix: true
21
- }
17
+ fix: true,
18
+ },
22
19
  };
23
- (0, _devkit.updateProjectConfiguration)(tree, options.fullyQualifiedName, projectConfiguration);
20
+ (0, devkit_1.updateProjectConfiguration)(tree, options.fullyQualifiedName, projectConfiguration);
24
21
  }
25
- const nxJson = (0, _devkit.readNxJson)(tree);
26
- var _nxJson_targetDefaults;
27
- (0, _devkit.updateNxJson)(tree, _extends._({}, nxJson, {
28
- targetDefaults: _extends._({}, (_nxJson_targetDefaults = nxJson.targetDefaults) != null ? _nxJson_targetDefaults : {}, {
29
- lint: {
22
+ const nxJson = (0, devkit_1.readNxJson)(tree);
23
+ (0, devkit_1.updateNxJson)(tree, Object.assign(Object.assign({}, nxJson), { targetDefaults: Object.assign(Object.assign({}, ((_a = nxJson.targetDefaults) !== null && _a !== void 0 ? _a : {})), { lint: {
30
24
  cache: true,
31
25
  inputs: [
32
26
  'default',
33
27
  '{workspaceRoot}/eslint.config.js',
34
- '{projectRoot}/eslint.config.js'
35
- ]
36
- }
37
- })
38
- }));
28
+ '{projectRoot}/eslint.config.js',
29
+ ],
30
+ } }) }));
39
31
  };
40
-
32
+ exports.configureEslint = configureEslint;
41
33
  //# sourceMappingURL=eslint.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/eslint.ts"],"sourcesContent":["import { readProjectConfiguration, Tree, updateProjectConfiguration, updateNxJson, readNxJson } from \"@nx/devkit\";\nimport { ConfigureProjectOptions } from \"./types\";\n\n\nexport const configureEslint = (tree: Tree, options: ConfigureProjectOptions) => {\n // Configure the lint task\n const projectConfiguration = readProjectConfiguration(tree, options.fullyQualifiedName);\n if (!projectConfiguration.targets.lint) {\n projectConfiguration.targets.lint = {\n executor: \"@nx/eslint:lint\",\n options: {\n fix: true,\n },\n }\n\n updateProjectConfiguration(tree, options.fullyQualifiedName, projectConfiguration);\n }\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n targetDefaults: {\n ...(nxJson.targetDefaults ?? {}),\n lint: {\n cache: true,\n inputs: [\n 'default',\n '{workspaceRoot}/eslint.config.js',\n '{projectRoot}/eslint.config.js',\n ],\n },\n },\n })\n}\n"],"names":["configureEslint","tree","options","projectConfiguration","readProjectConfiguration","fullyQualifiedName","targets","lint","executor","fix","updateProjectConfiguration","nxJson","readNxJson","updateNxJson","targetDefaults","cache","inputs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAIaA;;;eAAAA;;;;wBAJwF;AAI9F,MAAMA,kBAAkB,CAACC,MAAYC;IAC1C,0BAA0B;IAC1B,MAAMC,uBAAuBC,IAAAA,gCAAwB,EAACH,MAAMC,QAAQG,kBAAkB;IACtF,IAAI,CAACF,qBAAqBG,OAAO,CAACC,IAAI,EAAE;QACtCJ,qBAAqBG,OAAO,CAACC,IAAI,GAAG;YAClCC,UAAU;YACVN,SAAS;gBACPO,KAAK;YACP;QACF;QAEAC,IAAAA,kCAA0B,EAACT,MAAMC,QAAQG,kBAAkB,EAAEF;IAC/D;IAEA,MAAMQ,SAASC,IAAAA,kBAAU,EAACX;QAIlBU;IAHRE,IAAAA,oBAAY,EAACZ,MAAM,eACdU;QACHG,gBAAgB,eACVH,CAAAA,yBAAAA,OAAOG,cAAc,YAArBH,yBAAyB,CAAC;YAC9BJ,MAAM;gBACJQ,OAAO;gBACPC,QAAQ;oBACN;oBACA;oBACA;iBACD;YACH;;;AAGN"}
1
+ {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/eslint.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAMoB;AAGb,MAAM,eAAe,GAAG,CAC7B,IAAU,EACV,OAAgC,EAChC,EAAE;;IACF,0BAA0B;IAC1B,MAAM,oBAAoB,GAAG,IAAA,iCAAwB,EACnD,IAAI,EACJ,OAAO,CAAC,kBAAkB,CAC3B,CAAC;IACF,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACvC,oBAAoB,CAAC,OAAO,CAAC,IAAI,GAAG;YAClC,QAAQ,EAAE,iBAAiB;YAC3B,OAAO,EAAE;gBACP,GAAG,EAAE,IAAI;aACV;SACF,CAAC;QAEF,IAAA,mCAA0B,EACxB,IAAI,EACJ,OAAO,CAAC,kBAAkB,EAC1B,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;IAChC,IAAA,qBAAY,EAAC,IAAI,kCACZ,MAAM,KACT,cAAc,kCACT,CAAC,MAAA,MAAM,CAAC,cAAc,mCAAI,EAAE,CAAC,KAChC,IAAI,EAAE;gBACJ,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE;oBACN,SAAS;oBACT,kCAAkC;oBAClC,gCAAgC;iBACjC;aACF,OAEH,CAAC;AACL,CAAC,CAAC;AAvCW,QAAA,eAAe,mBAuC1B"}
@@ -1,5 +1,9 @@
1
- import { GeneratorCallback, Tree } from "@nx/devkit";
2
- import { TsLibGeneratorSchema } from "./schema";
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { GeneratorCallback, Tree } from '@nx/devkit';
6
+ import { TsLibGeneratorSchema } from './schema';
3
7
  export interface TsLibDetails {
4
8
  /**
5
9
  * Full package name including scope (eg @foo/bar)
@@ -1,61 +1,45 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- default: function() {
13
- return _default;
14
- },
15
- getTsLibDetails: function() {
16
- return getTsLibDetails;
17
- },
18
- tsLibGenerator: function() {
19
- return tsLibGenerator;
20
- }
21
- });
22
- const _extends = require("@swc/helpers/_/_extends");
23
- const _devkit = require("@nx/devkit");
24
- const _js = require("@nx/js");
25
- const _npmscope = require("../../utils/npm-scope");
26
- const _tsprojectutils = require("./ts-project-utils");
27
- const getTsLibDetails = (tree, schema)=>{
28
- const scope = schema.scope ? `${schema.scope}/` : (0, _npmscope.getNpmScopePrefix)(tree);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tsLibGenerator = exports.getTsLibDetails = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /**
6
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
+ * SPDX-License-Identifier: Apache-2.0
8
+ */
9
+ const devkit_1 = require("@nx/devkit");
10
+ const js_1 = require("@nx/js");
11
+ const npm_scope_1 = require("../../utils/npm-scope");
12
+ const ts_project_utils_1 = require("./ts-project-utils");
13
+ /**
14
+ * Returns details about the TS library to be created
15
+ */
16
+ const getTsLibDetails = (tree, schema) => {
17
+ var _a, _b;
18
+ const scope = schema.scope ? `${schema.scope}/` : (0, npm_scope_1.getNpmScopePrefix)(tree);
29
19
  const fullyQualifiedName = `${scope}${schema.name}`;
30
- var _schema_directory, _schema_subDirectory;
31
- const dir = (0, _devkit.joinPathFragments)((_schema_directory = schema.directory) != null ? _schema_directory : '.', (_schema_subDirectory = schema.subDirectory) != null ? _schema_subDirectory : schema.name);
32
- return {
33
- dir,
34
- fullyQualifiedName
35
- };
20
+ const dir = (0, devkit_1.joinPathFragments)((_a = schema.directory) !== null && _a !== void 0 ? _a : '.', (_b = schema.subDirectory) !== null && _b !== void 0 ? _b : schema.name);
21
+ return { dir, fullyQualifiedName };
36
22
  };
37
- const tsLibGenerator = async (tree, schema)=>{
38
- const { fullyQualifiedName, dir } = getTsLibDetails(tree, schema);
39
- await (0, _js.libraryGenerator)(tree, _extends._({}, schema, {
40
- name: fullyQualifiedName,
41
- directory: dir,
42
- projectNameAndRootFormat: 'as-provided',
43
- skipPackageJson: true,
44
- bundler: "tsc"
45
- }));
23
+ exports.getTsLibDetails = getTsLibDetails;
24
+ /**
25
+ * Generates a typescript library
26
+ */
27
+ const tsLibGenerator = (tree, schema) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
28
+ const { fullyQualifiedName, dir } = (0, exports.getTsLibDetails)(tree, schema);
29
+ yield (0, js_1.libraryGenerator)(tree, Object.assign(Object.assign({}, schema), { name: fullyQualifiedName, directory: dir, projectNameAndRootFormat: 'as-provided', skipPackageJson: true, bundler: 'tsc' }));
46
30
  // Replace with simpler sample source code
47
- tree.delete((0, _devkit.joinPathFragments)(dir, 'src'));
48
- (0, _devkit.generateFiles)(tree, (0, _devkit.joinPathFragments)(__dirname, 'files', 'src'), (0, _devkit.joinPathFragments)(dir, 'src'), {});
49
- (0, _tsprojectutils.configureTsProject)(tree, {
31
+ tree.delete((0, devkit_1.joinPathFragments)(dir, 'src'));
32
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'src'), (0, devkit_1.joinPathFragments)(dir, 'src'), {});
33
+ (0, ts_project_utils_1.configureTsProject)(tree, {
50
34
  dir,
51
- fullyQualifiedName
35
+ fullyQualifiedName,
52
36
  });
53
- return ()=>{
37
+ return () => {
54
38
  if (!schema.skipInstall) {
55
- (0, _devkit.installPackagesTask)(tree);
39
+ (0, devkit_1.installPackagesTask)(tree);
56
40
  }
57
41
  };
58
- };
59
- const _default = tsLibGenerator;
60
-
42
+ });
43
+ exports.tsLibGenerator = tsLibGenerator;
44
+ exports.default = exports.tsLibGenerator;
61
45
  //# sourceMappingURL=generator.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"sourcesContent":["import { GeneratorCallback, Tree, generateFiles, installPackagesTask, joinPathFragments } from \"@nx/devkit\";\nimport { TsLibGeneratorSchema } from \"./schema\";\nimport { libraryGenerator } from \"@nx/js\";\nimport { getNpmScopePrefix } from \"../../utils/npm-scope\";\nimport { configureTsProject } from \"./ts-project-utils\";\n\nexport interface TsLibDetails {\n /**\n * Full package name including scope (eg @foo/bar)\n */\n readonly fullyQualifiedName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n}\n\n/**\n * Returns details about the TS library to be created\n */\nexport const getTsLibDetails = (tree: Tree, schema: TsLibGeneratorSchema): TsLibDetails => {\n const scope = schema.scope ? `${schema.scope}/` : getNpmScopePrefix(tree);\n const fullyQualifiedName = `${scope}${schema.name}`;\n const dir = joinPathFragments(schema.directory ?? '.', schema.subDirectory ?? schema.name);\n\n return { dir, fullyQualifiedName };\n};\n\n/**\n * Generates a typescript library\n */\nexport const tsLibGenerator = async (tree: Tree, schema: TsLibGeneratorSchema): Promise<GeneratorCallback> => {\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, schema);\n\n await libraryGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: dir,\n projectNameAndRootFormat: 'as-provided',\n skipPackageJson: true,\n bundler: \"tsc\", // TODO: consider supporting others\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(dir, 'src'));\n generateFiles(\n tree, \n joinPathFragments(__dirname, 'files', 'src'), \n joinPathFragments(dir, 'src'), \n {}\n );\n\n configureTsProject(tree, {\n dir,\n fullyQualifiedName,\n });\n\n return () => {\n if (!schema.skipInstall) {\n installPackagesTask(tree);\n }\n };\n};\n\nexport default tsLibGenerator;\n"],"names":["getTsLibDetails","tsLibGenerator","tree","schema","scope","getNpmScopePrefix","fullyQualifiedName","name","dir","joinPathFragments","directory","subDirectory","libraryGenerator","projectNameAndRootFormat","skipPackageJson","bundler","delete","generateFiles","__dirname","configureTsProject","skipInstall","installPackagesTask"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAgEA,OAA8B;eAA9B;;IA5CaA,eAAe;eAAfA;;IAWAC,cAAc;eAAdA;;;;wBA/BkF;oBAE9D;0BACC;gCACC;AAgB5B,MAAMD,kBAAkB,CAACE,MAAYC;IAC1C,MAAMC,QAAQD,OAAOC,KAAK,GAAG,CAAC,EAAED,OAAOC,KAAK,CAAC,CAAC,CAAC,GAAGC,IAAAA,2BAAiB,EAACH;IACpE,MAAMI,qBAAqB,CAAC,EAAEF,MAAM,EAAED,OAAOI,IAAI,CAAC,CAAC;QACrBJ,mBAAyBA;IAAvD,MAAMK,MAAMC,IAAAA,yBAAiB,EAACN,CAAAA,oBAAAA,OAAOO,SAAS,YAAhBP,oBAAoB,KAAKA,CAAAA,uBAAAA,OAAOQ,YAAY,YAAnBR,uBAAuBA,OAAOI,IAAI;IAEzF,OAAO;QAAEC;QAAKF;IAAmB;AACnC;AAKO,MAAML,iBAAiB,OAAOC,MAAYC;IAC/C,MAAM,EAAEG,kBAAkB,EAAEE,GAAG,EAAE,GAAGR,gBAAgBE,MAAMC;IAE1D,MAAMS,IAAAA,oBAAgB,EAACV,MAAM,eACxBC;QACHI,MAAMD;QACNI,WAAWF;QACXK,0BAA0B;QAC1BC,iBAAiB;QACjBC,SAAS;;IAGX,0CAA0C;IAC1Cb,KAAKc,MAAM,CAACP,IAAAA,yBAAiB,EAACD,KAAK;IACnCS,IAAAA,qBAAa,EACXf,MACAO,IAAAA,yBAAiB,EAACS,WAAW,SAAS,QACtCT,IAAAA,yBAAiB,EAACD,KAAK,QACvB,CAAC;IAGHW,IAAAA,kCAAkB,EAACjB,MAAM;QACvBM;QACAF;IACF;IAEA,OAAO;QACL,IAAI,CAACH,OAAOiB,WAAW,EAAE;YACvBC,IAAAA,2BAAmB,EAACnB;QACtB;IACF;AACF;MAEA,WAAeD"}
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAMoB;AAEpB,+BAA0C;AAC1C,qDAA0D;AAC1D,yDAAwD;AAaxD;;GAEG;AACI,MAAM,eAAe,GAAG,CAC7B,IAAU,EACV,MAA4B,EACd,EAAE;;IAChB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC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AAC;QAC5B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAA,CAAC;AAlCW,QAAA,cAAc,kBAkCzB;AAEF,kBAAe,sBAAc,CAAC"}
@@ -1,4 +1,8 @@
1
- import { LibraryGeneratorSchema } from "@nx/js/src/utils/schema";
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { LibraryGeneratorSchema } from '@nx/js/src/utils/schema';
2
6
 
3
7
  export interface TsLibGeneratorSchema {
4
8
  name: LibraryGeneratorSchema['name'];
@@ -10,4 +14,4 @@ export interface TsLibGeneratorSchema {
10
14
  scope?: string;
11
15
  subDirectory?: string;
12
16
  skipInstall?: boolean;
13
- };
17
+ }
@@ -1,5 +1,9 @@
1
- import { Tree } from "@nx/devkit";
2
- import { ConfigureProjectOptions } from "./types";
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { Tree } from '@nx/devkit';
6
+ import { ConfigureProjectOptions } from './types';
3
7
  /**
4
8
  * Updates typescript projects
5
9
  */
@@ -1,107 +1,77 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "configureTsProject", {
6
- enumerable: true,
7
- get: function() {
8
- return configureTsProject;
9
- }
10
- });
11
- const _extends = require("@swc/helpers/_/_extends");
12
- const _devkit = require("@nx/devkit");
13
- const _path = require("path");
14
- const _generator = require("../cjs-to-esm/generator");
15
- const _npmscope = require("../../utils/npm-scope");
16
- const _vitest = require("./vitest");
17
- const _eslint = require("./eslint");
18
- const configureTsProject = (tree, options)=>{
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureTsProject = void 0;
4
+ /**
5
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ const devkit_1 = require("@nx/devkit");
9
+ const path_1 = require("path");
10
+ const generator_1 = require("../cjs-to-esm/generator");
11
+ const npm_scope_1 = require("../../utils/npm-scope");
12
+ const vitest_1 = require("./vitest");
13
+ const eslint_1 = require("./eslint");
14
+ /**
15
+ * Updates typescript projects
16
+ */
17
+ const configureTsProject = (tree, options) => {
19
18
  // Remove conflicting commonjs module from tsconfig
20
- (0, _devkit.updateJson)(tree, (0, _path.join)(options.dir, "tsconfig.json"), (tsConfig)=>{
21
- var _tsConfig_compilerOptions, _tsConfig_compilerOptions1;
22
- return _extends._({}, tsConfig, {
23
- compilerOptions: _extends._({}, tsConfig.compilerOptions, {
24
- module: ((_tsConfig_compilerOptions = tsConfig.compilerOptions) == null ? void 0 : _tsConfig_compilerOptions.module) === "commonjs" ? undefined : (_tsConfig_compilerOptions1 = tsConfig.compilerOptions) == null ? void 0 : _tsConfig_compilerOptions1.module
25
- })
26
- });
19
+ (0, devkit_1.updateJson)(tree, (0, path_1.join)(options.dir, 'tsconfig.json'), (tsConfig) => {
20
+ var _a, _b;
21
+ return (Object.assign(Object.assign({}, tsConfig), { compilerOptions: Object.assign(Object.assign({}, tsConfig.compilerOptions), { module: ((_a = tsConfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.module) === 'commonjs'
22
+ ? undefined
23
+ : (_b = tsConfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.module }) }));
27
24
  });
28
- const outDirToRootRelativePath = (0, _path.relative)((0, _path.join)(tree.root, options.dir), tree.root);
29
- const distDir = (0, _path.join)(outDirToRootRelativePath, "dist", options.dir);
25
+ const outDirToRootRelativePath = (0, path_1.relative)((0, path_1.join)(tree.root, options.dir), tree.root);
26
+ const distDir = (0, path_1.join)(outDirToRootRelativePath, 'dist', options.dir);
30
27
  // Remove baseUrl and rootDir from the tsconfig.lib.json
31
- if (tree.exists((0, _path.join)(options.dir, "tsconfig.lib.json"))) {
32
- (0, _devkit.updateJson)(tree, (0, _path.join)(options.dir, "tsconfig.lib.json"), (tsConfig)=>_extends._({}, tsConfig, {
33
- compilerOptions: _extends._({}, tsConfig.compilerOptions, {
34
- baseUrl: undefined,
35
- rootDir: undefined,
36
- outDir: distDir,
37
- tsBuildInfoFile: (0, _path.join)(distDir, "tsconfig.lib.tsbuildinfo")
38
- }),
39
- include: undefined
40
- }));
28
+ if (tree.exists((0, path_1.join)(options.dir, 'tsconfig.lib.json'))) {
29
+ (0, devkit_1.updateJson)(tree, (0, path_1.join)(options.dir, 'tsconfig.lib.json'), (tsConfig) => (Object.assign(Object.assign({}, tsConfig), { compilerOptions: Object.assign(Object.assign({}, tsConfig.compilerOptions), { baseUrl: undefined, rootDir: undefined, outDir: distDir, tsBuildInfoFile: (0, path_1.join)(distDir, 'tsconfig.lib.tsbuildinfo') }), include: undefined })));
41
30
  }
42
31
  // Update root project tsconfig
43
- (0, _devkit.updateJson)(tree, "tsconfig.base.json", (tsConfig)=>{
44
- var _tsConfig_compilerOptions;
45
- var _tsConfig_compilerOptions_paths;
46
- return _extends._({}, tsConfig, {
47
- compilerOptions: _extends._({}, tsConfig.compilerOptions, {
48
- baseUrl: '.',
49
- rootDir: '.',
50
- paths: _extends._({}, Object.fromEntries(Object.entries((_tsConfig_compilerOptions_paths = (_tsConfig_compilerOptions = tsConfig.compilerOptions) == null ? void 0 : _tsConfig_compilerOptions.paths) != null ? _tsConfig_compilerOptions_paths : {}).filter(([k])=>k !== options.fullyQualifiedName)), {
32
+ (0, devkit_1.updateJson)(tree, 'tsconfig.base.json', (tsConfig) => {
33
+ var _a, _b;
34
+ return (Object.assign(Object.assign({}, tsConfig), { compilerOptions: Object.assign(Object.assign({}, tsConfig.compilerOptions), { baseUrl: '.', rootDir: '.', paths: Object.assign(Object.assign({}, Object.fromEntries(Object.entries((_b = (_a = tsConfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths) !== null && _b !== void 0 ? _b : {}).filter(([k]) => k !== options.fullyQualifiedName))), {
51
35
  // Add aliases which begin with colon (eg :foo/bar) to avoid sniping attacks
52
- [(0, _npmscope.toScopeAlias)(options.fullyQualifiedName)]: [
53
- (0, _devkit.joinPathFragments)(options.dir, 'src', 'index.ts'),
54
- (0, _devkit.joinPathFragments)('dist', options.dir, 'src', 'index.d.ts')
55
- ]
56
- })
57
- })
58
- });
36
+ [(0, npm_scope_1.toScopeAlias)(options.fullyQualifiedName)]: [
37
+ (0, devkit_1.joinPathFragments)(options.dir, 'src', 'index.ts'),
38
+ (0, devkit_1.joinPathFragments)('dist', options.dir, 'src', 'index.d.ts'),
39
+ ] }) }) }));
59
40
  });
60
- if (tree.exists("tsconfig.json")) {
61
- (0, _devkit.updateJson)(tree, "tsconfig.json", (tsConfig)=>{
62
- var _tsConfig_references;
63
- return _extends._({}, tsConfig, {
64
- references: [
41
+ if (tree.exists('tsconfig.json')) {
42
+ (0, devkit_1.updateJson)(tree, 'tsconfig.json', (tsConfig) => {
43
+ var _a;
44
+ return (Object.assign(Object.assign({}, tsConfig), { references: [
65
45
  // Add project references, ensuring no duplication
66
- ...((_tsConfig_references = tsConfig.references) != null ? _tsConfig_references : []).filter((ref)=>ref.path !== `./${options.dir}`),
46
+ ...((_a = tsConfig.references) !== null && _a !== void 0 ? _a : []).filter((ref) => ref.path !== `./${options.dir}`),
67
47
  {
68
- path: `./${options.dir}`
69
- }
70
- ]
71
- });
48
+ path: `./${options.dir}`,
49
+ },
50
+ ] }));
72
51
  });
73
52
  }
74
53
  // Update the root package.json
75
- (0, _devkit.updateJson)(tree, "package.json", (packageJson)=>_extends._({}, packageJson, {
76
- type: "module"
77
- }));
54
+ (0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => (Object.assign(Object.assign({}, packageJson), { type: 'module' })));
78
55
  // Remove package.json if it exists
79
- if (tree.exists((0, _path.join)(options.dir, "package.json"))) {
80
- tree.delete((0, _path.join)(options.dir, "package.json"));
56
+ if (tree.exists((0, path_1.join)(options.dir, 'package.json'))) {
57
+ tree.delete((0, path_1.join)(options.dir, 'package.json'));
81
58
  }
82
59
  // Convert cjs files to esm for eslint configs and source code, including root monorepo config.
83
- (0, _generator.cjsToEsm)(tree, '.', {
84
- include: [
85
- "eslint.config.js",
86
- "**/eslint.config.js",
87
- "**/src/**/*.ts"
88
- ]
60
+ (0, generator_1.cjsToEsm)(tree, '.', {
61
+ include: ['eslint.config.js', '**/eslint.config.js', '**/src/**/*.ts'],
89
62
  });
90
63
  // Build task should both test and lint, so move build to compile and compose build as compile + test + lint
91
- const projectConfiguration = (0, _devkit.readProjectConfiguration)(tree, options.fullyQualifiedName);
92
- if (projectConfiguration.targets.build && projectConfiguration.targets.build.executor === "@nx/js:tsc") {
64
+ const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.fullyQualifiedName);
65
+ if (projectConfiguration.targets.build &&
66
+ projectConfiguration.targets.build.executor === '@nx/js:tsc') {
93
67
  projectConfiguration.targets.compile = projectConfiguration.targets.build;
94
68
  projectConfiguration.targets.build = {
95
- dependsOn: [
96
- "compile",
97
- "lint",
98
- "test"
99
- ]
69
+ dependsOn: ['compile', 'lint', 'test'],
100
70
  };
101
- (0, _devkit.updateProjectConfiguration)(tree, options.fullyQualifiedName, projectConfiguration);
71
+ (0, devkit_1.updateProjectConfiguration)(tree, options.fullyQualifiedName, projectConfiguration);
102
72
  }
103
- (0, _eslint.configureEslint)(tree, options);
104
- (0, _vitest.configureVitest)(tree, options);
73
+ (0, eslint_1.configureEslint)(tree, options);
74
+ (0, vitest_1.configureVitest)(tree, options);
105
75
  };
106
-
76
+ exports.configureTsProject = configureTsProject;
107
77
  //# sourceMappingURL=ts-project-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/ts-project-utils.ts"],"sourcesContent":["import { joinPathFragments, readProjectConfiguration, Tree, updateJson, updateProjectConfiguration } from \"@nx/devkit\";\nimport { join, relative } from \"path\";\nimport { cjsToEsm } from \"../cjs-to-esm/generator\";\nimport { toScopeAlias } from \"../../utils/npm-scope\";\nimport { ConfigureProjectOptions } from \"./types\";\nimport { configureVitest } from \"./vitest\";\nimport { configureEslint } from \"./eslint\";\n\n/**\n * Updates typescript projects\n */\nexport const configureTsProject = (tree: Tree, options: ConfigureProjectOptions) => {\n // Remove conflicting commonjs module from tsconfig\n updateJson(tree, join(options.dir, \"tsconfig.json\"), (tsConfig) => ({\n ...tsConfig,\n compilerOptions: {\n ...tsConfig.compilerOptions,\n module: tsConfig.compilerOptions?.module === \"commonjs\" ? undefined : tsConfig.compilerOptions?.module,\n },\n }));\n\n const outDirToRootRelativePath = relative(join(tree.root, options.dir), tree.root);\n const distDir = join(outDirToRootRelativePath, \"dist\", options.dir);\n\n // Remove baseUrl and rootDir from the tsconfig.lib.json\n if (tree.exists(join(options.dir, \"tsconfig.lib.json\"))) {\n updateJson(tree, join(options.dir, \"tsconfig.lib.json\"), (tsConfig) => ({\n ...tsConfig,\n compilerOptions: {\n ...tsConfig.compilerOptions,\n baseUrl: undefined,\n rootDir: undefined,\n outDir: distDir,\n tsBuildInfoFile: join(distDir, \"tsconfig.lib.tsbuildinfo\"),\n },\n include: undefined,\n }));\n }\n\n // Update root project tsconfig\n updateJson(tree, \"tsconfig.base.json\", (tsConfig) => ({\n ...tsConfig,\n compilerOptions: {\n ...tsConfig.compilerOptions,\n baseUrl: '.',\n rootDir: '.',\n paths: {\n // Remove any path aliases for this project with the npm scope prefix (eg remove @foo/bar)\n ...Object.fromEntries(Object.entries(tsConfig.compilerOptions?.paths ?? {}).filter(([k]) => k !== options.fullyQualifiedName)),\n // Add aliases which begin with colon (eg :foo/bar) to avoid sniping attacks\n [toScopeAlias(options.fullyQualifiedName)]: [\n joinPathFragments(options.dir, 'src', 'index.ts'),\n joinPathFragments('dist', options.dir, 'src', 'index.d.ts'),\n ],\n },\n },\n }));\n\n if (tree.exists(\"tsconfig.json\")) {\n updateJson(tree, \"tsconfig.json\", (tsConfig) => ({\n ...tsConfig,\n references: [\n // Add project references, ensuring no duplication\n ...(tsConfig.references ?? []).filter(ref => ref.path !== `./${options.dir}`),\n {\n path: `./${options.dir}`,\n },\n ],\n }));\n }\n\n // Update the root package.json\n updateJson(tree, \"package.json\", (packageJson) => ({\n ...packageJson,\n type: \"module\",\n }));\n\n // Remove package.json if it exists\n if (tree.exists(join(options.dir, \"package.json\"))) {\n tree.delete(join(options.dir, \"package.json\"));\n }\n\n // Convert cjs files to esm for eslint configs and source code, including root monorepo config.\n cjsToEsm(tree, '.', {\n include: [\"eslint.config.js\", \"**/eslint.config.js\", \"**/src/**/*.ts\"],\n });\n\n // Build task should both test and lint, so move build to compile and compose build as compile + test + lint\n const projectConfiguration = readProjectConfiguration(tree, options.fullyQualifiedName);\n if (projectConfiguration.targets.build && projectConfiguration.targets.build.executor === \"@nx/js:tsc\") {\n projectConfiguration.targets.compile = projectConfiguration.targets.build;\n projectConfiguration.targets.build = {\n dependsOn: [\"compile\", \"lint\", \"test\"],\n };\n\n updateProjectConfiguration(tree, options.fullyQualifiedName, projectConfiguration);\n }\n\n configureEslint(tree, options);\n configureVitest(tree, options);\n};\n"],"names":["configureTsProject","tree","options","updateJson","join","dir","tsConfig","compilerOptions","module","undefined","outDirToRootRelativePath","relative","root","distDir","exists","baseUrl","rootDir","outDir","tsBuildInfoFile","include","paths","Object","fromEntries","entries","filter","k","fullyQualifiedName","toScopeAlias","joinPathFragments","references","ref","path","packageJson","type","delete","cjsToEsm","projectConfiguration","readProjectConfiguration","targets","build","executor","compile","dependsOn","updateProjectConfiguration","configureEslint","configureVitest"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAWaA;;;eAAAA;;;;wBAX6F;sBAC3E;2BACN;0BACI;wBAEG;wBACA;AAKzB,MAAMA,qBAAqB,CAACC,MAAYC;IAC7C,mDAAmD;IACnDC,IAAAA,kBAAU,EAACF,MAAMG,IAAAA,UAAI,E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KAAK,GAAG;YACnC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;SACvC,CAAC;QAEF,IAAA,mCAA0B,EACxB,IAAI,EACJ,OAAO,CAAC,kBAAkB,EAC1B,oBAAoB,CACrB,CAAC;IACJ,CAAC;IAED,IAAA,wBAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAA,wBAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC;AAlHW,QAAA,kBAAkB,sBAkH7B"}
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
1
5
  export interface ConfigureProjectOptions {
2
6
  /**
3
7
  * Full package name including scope (eg @foo/bar)
@@ -1,6 +1,3 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/types.ts"],"names":[],"rangeMappings":"","mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/types.ts"],"names":[],"mappings":""}
@@ -1,3 +1,7 @@
1
- import { Tree } from "@nx/devkit";
2
- import { ConfigureProjectOptions } from "./types";
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { Tree } from '@nx/devkit';
6
+ import { ConfigureProjectOptions } from './types';
3
7
  export declare const configureVitest: (tree: Tree, options: ConfigureProjectOptions) => void;
@@ -1,67 +1,65 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "configureVitest", {
6
- enumerable: true,
7
- get: function() {
8
- return configureVitest;
9
- }
10
- });
11
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
12
- const _tsquery = require("@phenomnomnominal/tsquery");
13
- const _path = require("path");
14
- const _typescript = /*#__PURE__*/ _interop_require_default._(require("typescript"));
15
- const passWithNoTests = (sourceFile)=>{
16
- const transformer = (context)=>(rootNode)=>{
17
- function visit(node) {
18
- if (_typescript.default.isCallExpression(node) && _typescript.default.isIdentifier(node.expression) && node.expression.text === 'defineConfig' && node.arguments.length === 1) {
19
- const configObject = node.arguments[0];
20
- if (_typescript.default.isObjectLiteralExpression(configObject)) {
21
- const testProperty = configObject.properties.find((p)=>_typescript.default.isPropertyAssignment(p) && _typescript.default.isIdentifier(p.name) && p.name.text === 'test');
22
- if (testProperty && _typescript.default.isPropertyAssignment(testProperty)) {
23
- const testValue = testProperty.initializer;
24
- if (_typescript.default.isObjectLiteralExpression(testValue)) {
25
- // Check if passWithNoTests already exists
26
- const hasPassWithNoTests = testValue.properties.some((p)=>_typescript.default.isPropertyAssignment(p) && _typescript.default.isIdentifier(p.name) && p.name.text === 'passWithNoTests');
27
- if (!hasPassWithNoTests) {
28
- // Add passWithNoTests: true to the test object
29
- const newTestValue = context.factory.updateObjectLiteralExpression(testValue, [
30
- ...testValue.properties,
31
- context.factory.createPropertyAssignment('passWithNoTests', context.factory.createTrue())
32
- ]);
33
- // Update the test property with the new value
34
- const newTestProperty = context.factory.updatePropertyAssignment(testProperty, testProperty.name, newTestValue);
35
- // Update the config object with the new test property
36
- return context.factory.updateCallExpression(node, node.expression, node.typeArguments, [
37
- context.factory.updateObjectLiteralExpression(configObject, configObject.properties.map((p)=>p === testProperty ? newTestProperty : p))
38
- ]);
39
- }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureVitest = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
6
+ const path_1 = require("path");
7
+ const typescript_1 = tslib_1.__importDefault(require("typescript"));
8
+ const passWithNoTests = (sourceFile) => {
9
+ const transformer = (context) => (rootNode) => {
10
+ function visit(node) {
11
+ if (typescript_1.default.isCallExpression(node) &&
12
+ typescript_1.default.isIdentifier(node.expression) &&
13
+ node.expression.text === 'defineConfig' &&
14
+ node.arguments.length === 1) {
15
+ const configObject = node.arguments[0];
16
+ if (typescript_1.default.isObjectLiteralExpression(configObject)) {
17
+ const testProperty = configObject.properties.find((p) => typescript_1.default.isPropertyAssignment(p) &&
18
+ typescript_1.default.isIdentifier(p.name) &&
19
+ p.name.text === 'test');
20
+ if (testProperty && typescript_1.default.isPropertyAssignment(testProperty)) {
21
+ const testValue = testProperty.initializer;
22
+ if (typescript_1.default.isObjectLiteralExpression(testValue)) {
23
+ // Check if passWithNoTests already exists
24
+ const hasPassWithNoTests = testValue.properties.some((p) => typescript_1.default.isPropertyAssignment(p) &&
25
+ typescript_1.default.isIdentifier(p.name) &&
26
+ p.name.text === 'passWithNoTests');
27
+ if (!hasPassWithNoTests) {
28
+ // Add passWithNoTests: true to the test object
29
+ const newTestValue = context.factory.updateObjectLiteralExpression(testValue, [
30
+ ...testValue.properties,
31
+ context.factory.createPropertyAssignment('passWithNoTests', context.factory.createTrue()),
32
+ ]);
33
+ // Update the test property with the new value
34
+ const newTestProperty = context.factory.updatePropertyAssignment(testProperty, testProperty.name, newTestValue);
35
+ // Update the config object with the new test property
36
+ return context.factory.updateCallExpression(node, node.expression, node.typeArguments, [
37
+ context.factory.updateObjectLiteralExpression(configObject, configObject.properties.map((p) => p === testProperty ? newTestProperty : p)),
38
+ ]);
40
39
  }
41
40
  }
42
41
  }
43
42
  }
44
- return _typescript.default.visitEachChild(node, visit, context);
45
43
  }
46
- return _typescript.default.visitNode(rootNode, visit);
47
- };
48
- const result = _typescript.default.transform(sourceFile, [
49
- transformer
50
- ]);
44
+ return typescript_1.default.visitEachChild(node, visit, context);
45
+ }
46
+ return typescript_1.default.visitNode(rootNode, visit);
47
+ };
48
+ const result = typescript_1.default.transform(sourceFile, [transformer]);
51
49
  return result.transformed[0];
52
50
  };
53
- const configureVitest = (tree, options)=>{
54
- const configPath = (0, _path.join)(options.dir, "vite.config.ts");
51
+ const configureVitest = (tree, options) => {
52
+ const configPath = (0, path_1.join)(options.dir, 'vite.config.ts');
55
53
  if (tree.exists(configPath)) {
56
- const originalSourceFile = _tsquery.tsquery.ast(tree.read(configPath, "utf-8"));
54
+ const originalSourceFile = tsquery_1.tsquery.ast(tree.read(configPath, 'utf-8'));
57
55
  let sourceFile = originalSourceFile;
58
56
  sourceFile = passWithNoTests(sourceFile);
59
- const printer = _typescript.default.createPrinter({
57
+ const printer = typescript_1.default.createPrinter({
60
58
  removeComments: false,
61
- newLine: _typescript.default.NewLineKind.LineFeed
59
+ newLine: typescript_1.default.NewLineKind.LineFeed,
62
60
  });
63
- tree.write(configPath, printer.printNode(_typescript.default.EmitHint.Unspecified, sourceFile, originalSourceFile));
61
+ tree.write(configPath, printer.printNode(typescript_1.default.EmitHint.Unspecified, sourceFile, originalSourceFile));
64
62
  }
65
63
  };
66
-
64
+ exports.configureVitest = configureVitest;
67
65
  //# sourceMappingURL=vitest.js.map