@trackunit/iris-app 0.0.209 → 0.0.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -13
- package/src/generators/create/generator.js +20 -21
- package/src/generators/create/generator.js.map +1 -1
- package/src/generators/extend/generator.js +3 -2
- package/src/generators/extend/generator.js.map +1 -1
- package/src/index.d.ts +2 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -1
- package/src/utils/ast/astUtils.d.ts +17 -0
- package/src/utils/ast/astUtils.js +78 -0
- package/src/utils/ast/astUtils.js.map +1 -0
- package/src/utils/fileUpdater.d.ts +8 -0
- package/src/utils/fileUpdater.js +24 -0
- package/src/utils/fileUpdater.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.0.211](https://github.com/Trackunit/manager/compare/iris-app/0.0.210...iris-app/0.0.211) (2023-04-19)
|
|
6
|
+
|
|
7
|
+
## [0.0.210](https://github.com/Trackunit/manager/compare/iris-app/0.0.209...iris-app/0.0.210) (2023-04-19)
|
|
8
|
+
|
|
5
9
|
## [0.0.209](https://github.com/Trackunit/manager/compare/iris-app/0.0.208...iris-app/0.0.209) (2023-04-19)
|
|
6
10
|
|
|
7
11
|
### Dependency Updates
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.211",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"generators": "./generators.json",
|
|
@@ -39,21 +39,9 @@
|
|
|
39
39
|
"@heroicons/react": "2.0.16",
|
|
40
40
|
"@sentry/browser": "7.24.2",
|
|
41
41
|
"@trackunit/css-components": "0.0.315",
|
|
42
|
-
"@trackunit/css-core": "0.0.80",
|
|
43
|
-
"@trackunit/i18n-library-translation": "0.0.39",
|
|
44
42
|
"@trackunit/iris-app-api": "0.0.86",
|
|
45
43
|
"@trackunit/iris-app-build-utilities": "0.0.115",
|
|
46
|
-
"@trackunit/iris-app-runtime-core": "0.3.28",
|
|
47
|
-
"@trackunit/iris-app-runtime-core-api": "0.3.25",
|
|
48
44
|
"@trackunit/iris-app-webpack-plugin": "0.0.96",
|
|
49
|
-
"@trackunit/nx-utils": "0.0.9",
|
|
50
|
-
"@trackunit/react-components": "0.1.80",
|
|
51
|
-
"@trackunit/react-core-contexts-api": "0.2.24",
|
|
52
|
-
"@trackunit/react-core-contexts-test": "0.1.45",
|
|
53
|
-
"@trackunit/react-core-hooks": "0.2.41",
|
|
54
|
-
"@trackunit/tailwind-styled-components": "0.0.55",
|
|
55
|
-
"@trackunit/ui-design-tokens": "0.0.66",
|
|
56
|
-
"@trackunit/ui-icons": "0.0.63",
|
|
57
45
|
"capitalize": "2.0.4",
|
|
58
46
|
"date-fns": "2.29.3",
|
|
59
47
|
"glob": "7.2.3",
|
|
@@ -53,9 +53,8 @@ const IrisAppGenerator = async function (tree, options) {
|
|
|
53
53
|
const irisAppApiPackageJsonFromNpm = pacote.manifest("@trackunit/iris-app-api");
|
|
54
54
|
const irisAppBuildUtilitiesPackageJsonFromNpm = pacote.manifest("@trackunit/iris-app-build-utilities");
|
|
55
55
|
const irisAppWebpackPluginPackageJsonFromNpm = pacote.manifest("@trackunit/iris-app-webpack-plugin");
|
|
56
|
-
const nxUtilsPackageJsonFromNpm = pacote.manifest("@trackunit/nx-utils");
|
|
57
56
|
(0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
58
|
-
tslib: "
|
|
57
|
+
tslib: "2.4.0",
|
|
59
58
|
"@trackunit/react-components": (await reactComponentsPackageJsonFromNpm).version,
|
|
60
59
|
"@trackunit/react-core-contexts": (await reactCoreContextsPackageJsonFromNpm).version,
|
|
61
60
|
"@trackunit/css-components": (await cssComponentsPackageJsonFromNpm).version,
|
|
@@ -64,26 +63,26 @@ const IrisAppGenerator = async function (tree, options) {
|
|
|
64
63
|
"@trackunit/iris-app-api": (await irisAppApiPackageJsonFromNpm).version,
|
|
65
64
|
"@trackunit/iris-app-build-utilities": (await irisAppBuildUtilitiesPackageJsonFromNpm).version,
|
|
66
65
|
"@trackunit/iris-app-webpack-plugin": (await irisAppWebpackPluginPackageJsonFromNpm).version,
|
|
67
|
-
"@
|
|
68
|
-
"@nrwl/
|
|
69
|
-
"@nrwl/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"postcss-
|
|
75
|
-
"postcss-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
"@nrwl/react": "15.9.2",
|
|
67
|
+
"@nrwl/workspace": "15.9.2",
|
|
68
|
+
"@nrwl/devkit": "15.9.2",
|
|
69
|
+
eslint: "8.35.0",
|
|
70
|
+
"ts-morph": "15.1.0",
|
|
71
|
+
"esbuild-loader": "2.20.0",
|
|
72
|
+
"postcss-js": "4.0.0",
|
|
73
|
+
"postcss-loader": "6.2.1",
|
|
74
|
+
"postcss-nested": "5.0.6",
|
|
75
|
+
postcss: "8.4.19",
|
|
76
|
+
"style-loader": "3.3.0",
|
|
77
|
+
"json-loader": "0.5.7",
|
|
78
|
+
autoprefixer: "10.4.13",
|
|
79
|
+
"css-loader": "6.4.0",
|
|
80
|
+
webpack: "5.75.0",
|
|
81
|
+
tailwindcss: "3.2.4",
|
|
82
|
+
"ts-node": "10.9.1",
|
|
83
|
+
typescript: "4.9.5",
|
|
85
84
|
"webpack-dev-server": "4.10.0",
|
|
86
|
-
"webpack-cli": "
|
|
85
|
+
"webpack-cli": "4.10.0",
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
88
|
(0, devkit_1.addProjectConfiguration)(tree, normalizedOptions.projectName, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/create/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,uDAAiC;AACjC,mDAA6B;AAW7B,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAA+B;IACnE,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvF,MAAM,QAAQ,GAAG,SAAS,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC9E,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IACnD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAC9E,OAAO;QACL,GAAG,OAAO;QACV,WAAW;QACX,WAAW;QACX,gBAAgB;QAChB,QAAQ;QACR,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,OAAyB;IACrD,MAAM,eAAe,GAAG;QACtB,GAAG,OAAO;QACV,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC;QACtB,cAAc,EAAE,I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\n formatFiles,\n generateFiles,\n getWorkspaceLayout,\n installPackagesTask,\n names,\n offsetFromRoot,\n readJsonFile,\n Tree,\n} from \"@nrwl/devkit\";\nimport * as pacote from \"pacote\";\nimport * as path from \"path\";\nimport { IrisAppGeneratorSchema } from \"./schema\";\n\ninterface NormalizedSchema extends IrisAppGeneratorSchema {\n projectName: string;\n projectRoot: string;\n projectDirectory: string;\n toNxRoot: string;\n npmScope: string;\n}\n\nfunction normalizeOptions(tree: Tree, options: IrisAppGeneratorSchema): NormalizedSchema {\n const name = names(options.name).fileName;\n const projectDirectory = options.directory ? path.join(options.directory, name) : name;\n const toNxRoot = `../../${projectDirectory.indexOf(\"/\") !== -1 ? \"../\" : \"\"}`;\n const projectName = name.replace(new RegExp(\"/\", \"g\"), \"_\");\n const npmScope = getWorkspaceLayout(tree).npmScope;\n const projectRoot = `${getWorkspaceLayout(tree).appsDir}/${projectDirectory}`;\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n toNxRoot,\n npmScope,\n };\n}\n\nfunction addFiles(tree: Tree, options: NormalizedSchema) {\n const templateOptions = {\n ...options,\n ...names(options.name),\n offsetFromRoot: offsetFromRoot(options.projectRoot),\n template: \"\",\n };\n generateFiles(tree, path.join(__dirname, \"files\"), options.projectRoot, templateOptions);\n}\n\n/**\n * Iris App Generator.\n * This generator will create a new iris app, you can call this from your own generator.\n *\n * @param tree the nx tree\n * @param options the generator options\n * @returns { Promise<void> } void\n */\nexport const IrisAppGenerator = async function (tree: Tree, options: IrisAppGeneratorSchema) {\n const normalizedOptions = normalizeOptions(tree, options);\n const packageJsonFromNpm = await pacote.manifest(\"@trackunit/iris-app\");\n\n const packageJsonLocally = readJsonFile(path.join(__dirname, \"..\", \"..\", \"..\", \"package.json\"));\n\n if (options.updatePackageJson) {\n if (packageJsonFromNpm.version !== packageJsonLocally.version) {\n console.warn(\n `This version of the iris-app package does not match the version of the iris-app package from NPM JS. Please update using: npm i @trackunit/iris-app@${packageJsonFromNpm.version}`\n );\n }\n\n const reactComponentsPackageJsonFromNpm = pacote.manifest(\"@trackunit/react-components\");\n const reactCoreContextsPackageJsonFromNpm = pacote.manifest(\"@trackunit/react-core-contexts\");\n const cssComponentsPackageJsonFromNpm = pacote.manifest(\"@trackunit/css-components\");\n const cssTailwindPackageJsonFromNpm = pacote.manifest(\"@trackunit/css-tailwind\");\n const irisAppApiPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-api\");\n const irisAppBuildUtilitiesPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-build-utilities\");\n const irisAppWebpackPluginPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-webpack-plugin\");\n const nxUtilsPackageJsonFromNpm = pacote.manifest(\"@trackunit/nx-utils\");\n\n addDependenciesToPackageJson(\n tree,\n {\n tslib: \"^2.4.0\",\n \"@trackunit/react-components\": (await reactComponentsPackageJsonFromNpm).version,\n \"@trackunit/react-core-contexts\": (await reactCoreContextsPackageJsonFromNpm).version,\n \"@trackunit/css-components\": (await cssComponentsPackageJsonFromNpm).version,\n \"@trackunit/css-tailwind\": (await cssTailwindPackageJsonFromNpm).version,\n },\n {\n \"@trackunit/iris-app-api\": (await irisAppApiPackageJsonFromNpm).version,\n \"@trackunit/iris-app-build-utilities\": (await irisAppBuildUtilitiesPackageJsonFromNpm).version,\n \"@trackunit/iris-app-webpack-plugin\": (await irisAppWebpackPluginPackageJsonFromNpm).version,\n \"@trackunit/nx-utils\": (await nxUtilsPackageJsonFromNpm).version,\n \"@nrwl/react\": \"^15.9.2\",\n \"@nrwl/workspace\": \"^15.9.2\",\n \"@nrwl/devkit\": \"^15.9.2\",\n eslint: \"^8.35.0\",\n \"ts-morph\": \"^15.1.0\",\n \"esbuild-loader\": \"^2.20.0\",\n \"postcss-js\": \"^4.0.0\",\n \"postcss-loader\": \"^6.2.1\",\n \"postcss-nested\": \"^5.0.6\",\n postcss: \"^8.4.19\",\n \"style-loader\": \"^3.3.0\",\n \"json-loader\": \"^0.5.7\",\n autoprefixer: \"^10.4.13\",\n \"css-loader\": \"^6.4.0\",\n webpack: \"^5.75.0\",\n tailwindcss: \"^3.2.4\",\n \"ts-node\": \"^10.9.1\",\n \"webpack-dev-server\": \"4.10.0\",\n \"webpack-cli\": \"^4.10.0\",\n }\n );\n }\n addProjectConfiguration(tree, normalizedOptions.projectName, {\n root: normalizedOptions.projectRoot,\n projectType: \"application\",\n sourceRoot: `${normalizedOptions.projectRoot}/src`,\n targets: {\n build: {\n executor: \"@trackunit/iris-app:build\",\n options: {\n webpackConfig: `${normalizedOptions.projectRoot}/webpack.config.ts`,\n outputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n outputs: [\"{options.outputPath}\"],\n },\n serve: {\n executor: \"@trackunit/iris-app:serve\",\n options: {\n webpackConfig: `${normalizedOptions.projectRoot}/webpack.config.ts`,\n },\n outputs: [\"{options.outputPath}\"],\n },\n publishApp: {\n executor: \"@trackunit/iris-app:publish\",\n options: {\n inputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n dependsOn: [\n {\n target: \"build\",\n projects: \"self\",\n },\n ],\n outputs: [\"dist/\" + normalizedOptions.projectRoot],\n },\n },\n });\n addFiles(tree, normalizedOptions);\n // enforcing engine versions specified in package.json\n tree.write(\".npmrc\", \"engine-strict=true\");\n\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n };\n};\n\nexport default IrisAppGenerator;\n"]}
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/create/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,uDAAiC;AACjC,mDAA6B;AAW7B,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAA+B;IACnE,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,I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E;gBACV,QAAQ,EAAE,6BAA6B;gBACvC,OAAO,EAAE;oBACP,SAAS,EAAE,QAAQ,iBAAiB,CAAC,WAAW,EAAE;iBACnD;gBACD,SAAS,EAAE;oBACT;wBACE,MAAM,EAAE,OAAO;wBACf,QAAQ,EAAE,MAAM;qBACjB;iBACF;gBACD,OAAO,EAAE,CAAC,OAAO,GAAG,iBAAiB,CAAC,WAAW,CAAC;aACnD;SACF;KACF,CAAC,CAAC;IACH,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAClC,sDAAsD;IACtD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAE3C,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;AACJ,CAAC,CAAC;AApGW,QAAA,gBAAgB,oBAoG3B;AAEF,kBAAe,wBAAgB,CAAC","sourcesContent":["import {\n addDependenciesToPackageJson,\n addProjectConfiguration,\n formatFiles,\n generateFiles,\n getWorkspaceLayout,\n installPackagesTask,\n names,\n offsetFromRoot,\n readJsonFile,\n Tree,\n} from \"@nrwl/devkit\";\nimport * as pacote from \"pacote\";\nimport * as path from \"path\";\nimport { IrisAppGeneratorSchema } from \"./schema\";\n\ninterface NormalizedSchema extends IrisAppGeneratorSchema {\n projectName: string;\n projectRoot: string;\n projectDirectory: string;\n toNxRoot: string;\n npmScope: string;\n}\n\nfunction normalizeOptions(tree: Tree, options: IrisAppGeneratorSchema): NormalizedSchema {\n const name = names(options.name).fileName;\n const projectDirectory = options.directory ? path.join(options.directory, name) : name;\n const toNxRoot = `../../${projectDirectory.indexOf(\"/\") !== -1 ? \"../\" : \"\"}`;\n const projectName = name.replace(new RegExp(\"/\", \"g\"), \"_\");\n const npmScope = getWorkspaceLayout(tree).npmScope;\n const projectRoot = `${getWorkspaceLayout(tree).appsDir}/${projectDirectory}`;\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n toNxRoot,\n npmScope,\n };\n}\n\nfunction addFiles(tree: Tree, options: NormalizedSchema) {\n const templateOptions = {\n ...options,\n ...names(options.name),\n offsetFromRoot: offsetFromRoot(options.projectRoot),\n template: \"\",\n };\n generateFiles(tree, path.join(__dirname, \"files\"), options.projectRoot, templateOptions);\n}\n\n/**\n * Iris App Generator.\n * This generator will create a new iris app, you can call this from your own generator.\n *\n * @param tree the nx tree\n * @param options the generator options\n * @returns { Promise<void> } void\n */\nexport const IrisAppGenerator = async function (tree: Tree, options: IrisAppGeneratorSchema) {\n const normalizedOptions = normalizeOptions(tree, options);\n const packageJsonFromNpm = await pacote.manifest(\"@trackunit/iris-app\");\n\n const packageJsonLocally = readJsonFile(path.join(__dirname, \"..\", \"..\", \"..\", \"package.json\"));\n\n if (options.updatePackageJson) {\n if (packageJsonFromNpm.version !== packageJsonLocally.version) {\n console.warn(\n `This version of the iris-app package does not match the version of the iris-app package from NPM JS. Please update using: npm i @trackunit/iris-app@${packageJsonFromNpm.version}`\n );\n }\n\n const reactComponentsPackageJsonFromNpm = pacote.manifest(\"@trackunit/react-components\");\n const reactCoreContextsPackageJsonFromNpm = pacote.manifest(\"@trackunit/react-core-contexts\");\n const cssComponentsPackageJsonFromNpm = pacote.manifest(\"@trackunit/css-components\");\n const cssTailwindPackageJsonFromNpm = pacote.manifest(\"@trackunit/css-tailwind\");\n const irisAppApiPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-api\");\n const irisAppBuildUtilitiesPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-build-utilities\");\n const irisAppWebpackPluginPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-webpack-plugin\");\n\n addDependenciesToPackageJson(\n tree,\n {\n tslib: \"2.4.0\",\n \"@trackunit/react-components\": (await reactComponentsPackageJsonFromNpm).version,\n \"@trackunit/react-core-contexts\": (await reactCoreContextsPackageJsonFromNpm).version,\n \"@trackunit/css-components\": (await cssComponentsPackageJsonFromNpm).version,\n \"@trackunit/css-tailwind\": (await cssTailwindPackageJsonFromNpm).version,\n },\n {\n \"@trackunit/iris-app-api\": (await irisAppApiPackageJsonFromNpm).version,\n \"@trackunit/iris-app-build-utilities\": (await irisAppBuildUtilitiesPackageJsonFromNpm).version,\n \"@trackunit/iris-app-webpack-plugin\": (await irisAppWebpackPluginPackageJsonFromNpm).version,\n \"@nrwl/react\": \"15.9.2\",\n \"@nrwl/workspace\": \"15.9.2\",\n \"@nrwl/devkit\": \"15.9.2\",\n eslint: \"8.35.0\",\n \"ts-morph\": \"15.1.0\",\n \"esbuild-loader\": \"2.20.0\",\n \"postcss-js\": \"4.0.0\",\n \"postcss-loader\": \"6.2.1\",\n \"postcss-nested\": \"5.0.6\",\n postcss: \"8.4.19\",\n \"style-loader\": \"3.3.0\",\n \"json-loader\": \"0.5.7\",\n autoprefixer: \"10.4.13\",\n \"css-loader\": \"6.4.0\",\n webpack: \"5.75.0\",\n tailwindcss: \"3.2.4\",\n \"ts-node\": \"10.9.1\",\n typescript: \"4.9.5\",\n \"webpack-dev-server\": \"4.10.0\",\n \"webpack-cli\": \"4.10.0\",\n }\n );\n }\n addProjectConfiguration(tree, normalizedOptions.projectName, {\n root: normalizedOptions.projectRoot,\n projectType: \"application\",\n sourceRoot: `${normalizedOptions.projectRoot}/src`,\n targets: {\n build: {\n executor: \"@trackunit/iris-app:build\",\n options: {\n webpackConfig: `${normalizedOptions.projectRoot}/webpack.config.ts`,\n outputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n outputs: [\"{options.outputPath}\"],\n },\n serve: {\n executor: \"@trackunit/iris-app:serve\",\n options: {\n webpackConfig: `${normalizedOptions.projectRoot}/webpack.config.ts`,\n },\n outputs: [\"{options.outputPath}\"],\n },\n publishApp: {\n executor: \"@trackunit/iris-app:publish\",\n options: {\n inputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n dependsOn: [\n {\n target: \"build\",\n projects: \"self\",\n },\n ],\n outputs: [\"dist/\" + normalizedOptions.projectRoot],\n },\n },\n });\n addFiles(tree, normalizedOptions);\n // enforcing engine versions specified in package.json\n tree.write(\".npmrc\", \"engine-strict=true\");\n\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n };\n};\n\nexport default IrisAppGenerator;\n"]}
|
|
@@ -6,12 +6,13 @@ const devkit_1 = require("@nrwl/devkit");
|
|
|
6
6
|
const js_1 = require("@nrwl/js");
|
|
7
7
|
const linter_1 = require("@nrwl/linter");
|
|
8
8
|
const react_1 = require("@nrwl/react");
|
|
9
|
-
const nx_utils_1 = require("@trackunit/nx-utils");
|
|
10
9
|
const camelcase_1 = tslib_1.__importDefault(require("camelcase"));
|
|
11
10
|
const enquirer_1 = require("enquirer");
|
|
12
11
|
const fs = tslib_1.__importStar(require("fs"));
|
|
13
12
|
const path = tslib_1.__importStar(require("path"));
|
|
14
13
|
const ts_morph_1 = require("ts-morph");
|
|
14
|
+
const astUtils_1 = require("../../utils/ast/astUtils");
|
|
15
|
+
const fileUpdater_1 = require("../../utils/fileUpdater");
|
|
15
16
|
const singleSpaDependencies_1 = require("./singleSpaDependencies");
|
|
16
17
|
function normalizeOptions(tree, options) {
|
|
17
18
|
const name = (0, devkit_1.names)(options.name).fileName;
|
|
@@ -113,7 +114,7 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
113
114
|
tsConfigLib.include = [...tsConfigLib.include, "extension-manifest.ts"];
|
|
114
115
|
return tsConfigLib;
|
|
115
116
|
});
|
|
116
|
-
(0,
|
|
117
|
+
(0, fileUpdater_1.updateFileInTree)(tree, (0, devkit_1.joinPathFragments)(normalizedOptions.projectRoot, "jest.config.ts"), fileContent => (0, astUtils_1.addPropertyWithName)(fileContent, "moduleNameMapper", { "@trackunit/css-core": "jest-transform-stub" }));
|
|
117
118
|
await (0, devkit_1.formatFiles)(tree);
|
|
118
119
|
return () => {
|
|
119
120
|
(0, devkit_1.installPackagesTask)(tree, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/extend/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,iCAAqD;AACrD,yCAAsC;AACtC,uCAA+C;AAE/C,kDAA4E;AAC5E,kEAAkC;AAClC,uCAAkC;AAClC,+CAAyB;AACzB,mDAA6B;AAC7B,uCAAqD;AAErD,mEAA0D;AAW1D,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAAwC;IAC5E,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnG,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACxE,MAAM,gBAAgB,GAAG,IAAA,mBAAS,EAAC,IAAI,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,GAAG,QAAQ,CAAC,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAC9D,MAAM,UAAU,GAAG,GAAG,QAAQ,CAAC,OAAO,IAAI,gBAAgB,MAAM,CAAC;IACjE,MAAM,UAAU,GAAG,IAAI,QAAQ,CAAC,QAAQ,IAAI,gBAAgB,EAAE,CAAC;IAE/D,OAAO;QACL,GAAG,OAAO;QACV,WAAW;QACX,WAAW;QACX,gBAAgB;QAChB,gBAAgB;QAChB,UAAU;QACV,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACI,MAAM,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AAC,CAAC;AAEF,kBAAe,iCAAyB,CAAC","sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n generateFiles,\n getWorkspaceLayout,\n installPackagesTask,\n joinPathFragments,\n names,\n offsetFromRoot,\n Tree,\n updateJson,\n} from \"@nrwl/devkit\";\nimport { getRootTsConfigPathInTree } from \"@nrwl/js\";\nimport { Linter } from \"@nrwl/linter\";\nimport { libraryGenerator } from \"@nrwl/react\";\nimport { Schema } from \"@nrwl/react/src/generators/library/schema\";\nimport { addPropertyWithName, updateFileInTree } from \"@trackunit/nx-utils\";\nimport camelCase from \"camelcase\";\nimport { prompt } from \"enquirer\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { Node, Project, SyntaxKind } from \"ts-morph\";\nimport { IrisAppExtensionGeneratorSchema } from \"./schema\";\nimport { spaDependencies } from \"./singleSpaDependencies\";\n\ninterface NormalizedSchema extends IrisAppExtensionGeneratorSchema {\n projectName: string;\n projectRoot: string;\n projectDirectory: string;\n projectCamelcase: string;\n importPath: string;\n sourceRoot: string;\n}\n\nfunction normalizeOptions(tree: Tree, options: IrisAppExtensionGeneratorSchema): NormalizedSchema {\n const name = names(options.name).fileName;\n const projectDirectory = options.directory ? `${names(options.directory).fileName}/${name}` : name;\n const projectName = projectDirectory.replace(new RegExp(\"/\", \"g\"), \"-\");\n const projectCamelcase = camelCase(name);\n const wsLayout = getWorkspaceLayout(tree);\n const projectRoot = `${wsLayout.libsDir}/${projectDirectory}`;\n const sourceRoot = `${wsLayout.libsDir}/${projectDirectory}/src`;\n const importPath = `@${wsLayout.npmScope}/${projectDirectory}`;\n\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n projectCamelcase,\n importPath,\n sourceRoot,\n };\n}\n\n/**\n * Iris App Extension Generator.\n *\n * @param tree the nx tree\n * @param options the generator options\n * @returns { Promise<void> } void\n */\nexport const IrisAppExtensionGenerator = async function (tree: Tree, options: IrisAppExtensionGeneratorSchema) {\n const adjustedOptions = await updateAppName(tree, options);\n\n const normalizedOptions = normalizeOptions(tree, adjustedOptions);\n\n const templateOptions = {\n ...normalizedOptions,\n ...names(normalizedOptions.name),\n offsetFromRoot: offsetFromRoot(normalizedOptions.projectRoot),\n template: \"\",\n };\n const irisAppExtensionType = normalizedOptions.type;\n\n if (!tree.exists(`${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}`)) {\n throw new Error(\n `The app does not exist: ${getWorkspaceLayout(tree).appsDir}/${\n normalizedOptions.app\n } make sure you enter the right app name`\n );\n }\n\n const manifestPath = `${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}/iris-app-manifest.ts`;\n if (!tree.exists(manifestPath)) {\n throw new Error(\n `The app does not have an iris-app-manifest.ts: ${manifestPath} make sure you enter the right app name, which has an iris-app-manifest.ts`\n );\n }\n generateFiles(\n tree,\n path.join(__dirname, \"files\", irisAppExtensionType),\n normalizedOptions.projectRoot,\n templateOptions\n );\n\n if (normalizedOptions.updatePackageJson) {\n addDependenciesToPackageJson(\n tree,\n {},\n {\n ...spaDependencies,\n }\n );\n }\n\n const schema: Schema = {\n name: normalizedOptions.name,\n style: \"none\",\n skipFormat: false,\n strict: true,\n unitTestRunner: \"jest\",\n linter: Linter.EsLint,\n routing: false,\n pascalCaseFiles: true,\n directory: normalizedOptions.directory,\n skipTsConfig: false,\n skipPackageJson: true,\n standaloneConfig: true,\n };\n await libraryGenerator(tree, schema);\n\n if (irisAppExtensionType !== \"REPORT_EXTENSION\") {\n generateFiles(tree, path.join(__dirname, \"files\", \"react-app\"), normalizedOptions.projectRoot, templateOptions);\n }\n\n const rootTsConfigPath = getRootTsConfigPathInTree(tree);\n if (!rootTsConfigPath) {\n throw new Error(\"Could not find root tsconfig.json\");\n }\n updateJson(tree, rootTsConfigPath, tsConfigBase => {\n tsConfigBase.compilerOptions.paths[normalizedOptions.importPath] = [\n path.join(normalizedOptions.projectRoot, \"extension-manifest.ts\"),\n ];\n return tsConfigBase;\n });\n\n //TODO: Change the following to update the manifest in the virtual Tree - not on the file system.\n const project = new Project({\n tsConfigFilePath: `${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}/tsconfig.app.json`,\n });\n\n const manifest = project.getSourceFileOrThrow(manifestPath);\n\n manifest.addImportDeclaration({\n moduleSpecifier: normalizedOptions.importPath,\n defaultImport: normalizedOptions.projectCamelcase,\n });\n\n manifest.forEachDescendant(node => {\n if (Node.isPropertyAssignment(node)) {\n if (node.getText().indexOf(\"extensions\") !== -1) {\n const array = node.getFirstChildByKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n array.addElement(`${normalizedOptions.projectCamelcase}`);\n }\n }\n });\n await manifest.save();\n\n tree.delete(joinPathFragments(normalizedOptions.projectRoot, \"src\", \"index.ts\"));\n\n updateJson(tree, joinPathFragments(normalizedOptions.projectRoot, \"tsconfig.lib.json\"), tsConfigLib => {\n tsConfigLib.include = [...tsConfigLib.include, \"extension-manifest.ts\"];\n return tsConfigLib;\n });\n\n updateFileInTree(tree, joinPathFragments(normalizedOptions.projectRoot, \"jest.config.ts\"), fileContent =>\n addPropertyWithName(fileContent, \"moduleNameMapper\", { \"@trackunit/css-core\": \"jest-transform-stub\" })\n );\n\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n };\n};\nconst updateAppName = async (tree: Tree, options: IrisAppExtensionGeneratorSchema) => {\n if (!options.app) {\n const folders = fs\n .readdirSync(getWorkspaceLayout(tree).appsDir, { withFileTypes: true })\n .filter(item => item.isDirectory());\n\n const tileApps: string[] = [];\n\n folders.forEach(folder => {\n const irisAppManifest = fs\n .readdirSync(`${getWorkspaceLayout(tree).appsDir}/${folder.name}`, { withFileTypes: true })\n .find(item => item.name === \"iris-app-manifest.ts\");\n\n if (irisAppManifest) {\n tileApps.push(folder.name);\n } else {\n const subFolders = fs\n .readdirSync(path.join(getWorkspaceLayout(tree).appsDir, folder.name), { withFileTypes: true })\n .filter(item => item.isDirectory());\n subFolders.forEach(subFolder => {\n const subDirIrisAppManifest = fs\n .readdirSync(`${getWorkspaceLayout(tree).appsDir}/${folder.name}/${subFolder.name}`, {\n withFileTypes: true,\n })\n .find(item => item.name === \"iris-app-manifest.ts\");\n\n if (subDirIrisAppManifest) {\n tileApps.push(path.join(folder.name, subFolder.name));\n }\n });\n }\n });\n\n if (tileApps.length === 1) {\n options.app = tileApps[0];\n } else if (tileApps.length === 0) {\n throw new Error(\"Please add an iris-app using: nx g @trackunit/iris-app:create \");\n } else {\n const promptObject = {\n name: \"app\",\n message: \"Select iris-app for this extension:\",\n type: \"select\",\n choices: tileApps.map(item => item),\n };\n await prompt(promptObject).then((values: object) => {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n options.app = values[\"app\"];\n });\n }\n }\n return options;\n};\n\nexport default IrisAppExtensionGenerator;\n"]}
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/extend/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,iCAAqD;AACrD,yCAAsC;AACtC,uCAA+C;AAE/C,kEAAkC;AAClC,uCAAkC;AAClC,+CAAyB;AACzB,mDAA6B;AAC7B,uCAAqD;AACrD,uDAA+D;AAC/D,yDAA2D;AAE3D,mEAA0D;AAW1D,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAAwC;IAC5E,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnG,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACxE,MAAM,gBAAgB,GAAG,IAAA,mBAAS,E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AI,KAAK,CAAC,gEAAgE,CAAC,CAAC;SACnF;aAAM;YACL,MAAM,YAAY,GAAG;gBACnB,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,qCAAqC;gBAC9C,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;aACpC,CAAC;YACF,MAAM,IAAA,iBAAM,EAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE;gBACjD,2DAA2D;gBAC3D,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;SACJ;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,kBAAe,iCAAyB,CAAC","sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n generateFiles,\n getWorkspaceLayout,\n installPackagesTask,\n joinPathFragments,\n names,\n offsetFromRoot,\n Tree,\n updateJson,\n} from \"@nrwl/devkit\";\nimport { getRootTsConfigPathInTree } from \"@nrwl/js\";\nimport { Linter } from \"@nrwl/linter\";\nimport { libraryGenerator } from \"@nrwl/react\";\nimport { Schema } from \"@nrwl/react/src/generators/library/schema\";\nimport camelCase from \"camelcase\";\nimport { prompt } from \"enquirer\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { Node, Project, SyntaxKind } from \"ts-morph\";\nimport { addPropertyWithName } from \"../../utils/ast/astUtils\";\nimport { updateFileInTree } from \"../../utils/fileUpdater\";\nimport { IrisAppExtensionGeneratorSchema } from \"./schema\";\nimport { spaDependencies } from \"./singleSpaDependencies\";\n\ninterface NormalizedSchema extends IrisAppExtensionGeneratorSchema {\n projectName: string;\n projectRoot: string;\n projectDirectory: string;\n projectCamelcase: string;\n importPath: string;\n sourceRoot: string;\n}\n\nfunction normalizeOptions(tree: Tree, options: IrisAppExtensionGeneratorSchema): NormalizedSchema {\n const name = names(options.name).fileName;\n const projectDirectory = options.directory ? `${names(options.directory).fileName}/${name}` : name;\n const projectName = projectDirectory.replace(new RegExp(\"/\", \"g\"), \"-\");\n const projectCamelcase = camelCase(name);\n const wsLayout = getWorkspaceLayout(tree);\n const projectRoot = `${wsLayout.libsDir}/${projectDirectory}`;\n const sourceRoot = `${wsLayout.libsDir}/${projectDirectory}/src`;\n const importPath = `@${wsLayout.npmScope}/${projectDirectory}`;\n\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n projectCamelcase,\n importPath,\n sourceRoot,\n };\n}\n\n/**\n * Iris App Extension Generator.\n *\n * @param tree the nx tree\n * @param options the generator options\n * @returns { Promise<void> } void\n */\nexport const IrisAppExtensionGenerator = async function (tree: Tree, options: IrisAppExtensionGeneratorSchema) {\n const adjustedOptions = await updateAppName(tree, options);\n\n const normalizedOptions = normalizeOptions(tree, adjustedOptions);\n\n const templateOptions = {\n ...normalizedOptions,\n ...names(normalizedOptions.name),\n offsetFromRoot: offsetFromRoot(normalizedOptions.projectRoot),\n template: \"\",\n };\n const irisAppExtensionType = normalizedOptions.type;\n\n if (!tree.exists(`${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}`)) {\n throw new Error(\n `The app does not exist: ${getWorkspaceLayout(tree).appsDir}/${\n normalizedOptions.app\n } make sure you enter the right app name`\n );\n }\n\n const manifestPath = `${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}/iris-app-manifest.ts`;\n if (!tree.exists(manifestPath)) {\n throw new Error(\n `The app does not have an iris-app-manifest.ts: ${manifestPath} make sure you enter the right app name, which has an iris-app-manifest.ts`\n );\n }\n generateFiles(\n tree,\n path.join(__dirname, \"files\", irisAppExtensionType),\n normalizedOptions.projectRoot,\n templateOptions\n );\n\n if (normalizedOptions.updatePackageJson) {\n addDependenciesToPackageJson(\n tree,\n {},\n {\n ...spaDependencies,\n }\n );\n }\n\n const schema: Schema = {\n name: normalizedOptions.name,\n style: \"none\",\n skipFormat: false,\n strict: true,\n unitTestRunner: \"jest\",\n linter: Linter.EsLint,\n routing: false,\n pascalCaseFiles: true,\n directory: normalizedOptions.directory,\n skipTsConfig: false,\n skipPackageJson: true,\n standaloneConfig: true,\n };\n await libraryGenerator(tree, schema);\n\n if (irisAppExtensionType !== \"REPORT_EXTENSION\") {\n generateFiles(tree, path.join(__dirname, \"files\", \"react-app\"), normalizedOptions.projectRoot, templateOptions);\n }\n\n const rootTsConfigPath = getRootTsConfigPathInTree(tree);\n if (!rootTsConfigPath) {\n throw new Error(\"Could not find root tsconfig.json\");\n }\n updateJson(tree, rootTsConfigPath, tsConfigBase => {\n tsConfigBase.compilerOptions.paths[normalizedOptions.importPath] = [\n path.join(normalizedOptions.projectRoot, \"extension-manifest.ts\"),\n ];\n return tsConfigBase;\n });\n\n //TODO: Change the following to update the manifest in the virtual Tree - not on the file system.\n const project = new Project({\n tsConfigFilePath: `${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}/tsconfig.app.json`,\n });\n\n const manifest = project.getSourceFileOrThrow(manifestPath);\n\n manifest.addImportDeclaration({\n moduleSpecifier: normalizedOptions.importPath,\n defaultImport: normalizedOptions.projectCamelcase,\n });\n\n manifest.forEachDescendant(node => {\n if (Node.isPropertyAssignment(node)) {\n if (node.getText().indexOf(\"extensions\") !== -1) {\n const array = node.getFirstChildByKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n array.addElement(`${normalizedOptions.projectCamelcase}`);\n }\n }\n });\n await manifest.save();\n\n tree.delete(joinPathFragments(normalizedOptions.projectRoot, \"src\", \"index.ts\"));\n\n updateJson(tree, joinPathFragments(normalizedOptions.projectRoot, \"tsconfig.lib.json\"), tsConfigLib => {\n tsConfigLib.include = [...tsConfigLib.include, \"extension-manifest.ts\"];\n return tsConfigLib;\n });\n\n updateFileInTree(tree, joinPathFragments(normalizedOptions.projectRoot, \"jest.config.ts\"), fileContent =>\n addPropertyWithName(fileContent, \"moduleNameMapper\", { \"@trackunit/css-core\": \"jest-transform-stub\" })\n );\n\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n };\n};\nconst updateAppName = async (tree: Tree, options: IrisAppExtensionGeneratorSchema) => {\n if (!options.app) {\n const folders = fs\n .readdirSync(getWorkspaceLayout(tree).appsDir, { withFileTypes: true })\n .filter(item => item.isDirectory());\n\n const tileApps: string[] = [];\n\n folders.forEach(folder => {\n const irisAppManifest = fs\n .readdirSync(`${getWorkspaceLayout(tree).appsDir}/${folder.name}`, { withFileTypes: true })\n .find(item => item.name === \"iris-app-manifest.ts\");\n\n if (irisAppManifest) {\n tileApps.push(folder.name);\n } else {\n const subFolders = fs\n .readdirSync(path.join(getWorkspaceLayout(tree).appsDir, folder.name), { withFileTypes: true })\n .filter(item => item.isDirectory());\n subFolders.forEach(subFolder => {\n const subDirIrisAppManifest = fs\n .readdirSync(`${getWorkspaceLayout(tree).appsDir}/${folder.name}/${subFolder.name}`, {\n withFileTypes: true,\n })\n .find(item => item.name === \"iris-app-manifest.ts\");\n\n if (subDirIrisAppManifest) {\n tileApps.push(path.join(folder.name, subFolder.name));\n }\n });\n }\n });\n\n if (tileApps.length === 1) {\n options.app = tileApps[0];\n } else if (tileApps.length === 0) {\n throw new Error(\"Please add an iris-app using: nx g @trackunit/iris-app:create \");\n } else {\n const promptObject = {\n name: \"app\",\n message: \"Select iris-app for this extension:\",\n type: \"select\",\n choices: tileApps.map(item => item),\n };\n await prompt(promptObject).then((values: object) => {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n options.app = values[\"app\"];\n });\n }\n }\n return options;\n};\n\nexport default IrisAppExtensionGenerator;\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { IrisAppGenerator } from "./generators/create/generator";
|
|
|
2
2
|
export { IrisAppGeneratorSchema } from "./generators/create/schema";
|
|
3
3
|
export { IrisAppExtensionGenerator } from "./generators/extend/generator";
|
|
4
4
|
export { IrisAppExtensionGeneratorSchema } from "./generators/extend/schema";
|
|
5
|
+
export * from "./utils/ast/astUtils";
|
|
6
|
+
export * from "./utils/fileUpdater";
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IrisAppExtensionGenerator = exports.IrisAppGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
var generator_1 = require("./generators/create/generator");
|
|
5
6
|
Object.defineProperty(exports, "IrisAppGenerator", { enumerable: true, get: function () { return generator_1.IrisAppGenerator; } });
|
|
6
7
|
var generator_2 = require("./generators/extend/generator");
|
|
7
8
|
Object.defineProperty(exports, "IrisAppExtensionGenerator", { enumerable: true, get: function () { return generator_2.IrisAppExtensionGenerator; } });
|
|
9
|
+
tslib_1.__exportStar(require("./utils/ast/astUtils"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./utils/fileUpdater"), exports);
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/iris-app-sdk/iris-app/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/iris-app-sdk/iris-app/src/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAiE;AAAxD,6GAAA,gBAAgB,OAAA;AAEzB,2DAA0E;AAAjE,sHAAA,yBAAyB,OAAA;AAElC,+DAAqC;AACrC,8DAAoC","sourcesContent":["export { IrisAppGenerator } from \"./generators/create/generator\";\nexport { IrisAppGeneratorSchema } from \"./generators/create/schema\";\nexport { IrisAppExtensionGenerator } from \"./generators/extend/generator\";\nexport { IrisAppExtensionGeneratorSchema } from \"./generators/extend/schema\";\nexport * from \"./utils/ast/astUtils\";\nexport * from \"./utils/fileUpdater\";\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function removes a property with a given name from an object literal
|
|
3
|
+
* provided as a text string.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} fileContent The source code as text
|
|
6
|
+
* @param {string} propertyNames The properties to remove from the object
|
|
7
|
+
*/
|
|
8
|
+
export declare function removePropertyWithName(fileContent: string, ...propertyNames: string[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* This function adds a new property with a given name and value to an object literal
|
|
11
|
+
* provided as a text string.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} fileContent - the source code as text
|
|
14
|
+
* @param {string} propertyName - the name of the property to add
|
|
15
|
+
* @param {string | string[]} propertyValue - the value of the property to add
|
|
16
|
+
*/
|
|
17
|
+
export declare function addPropertyWithName(fileContent: string, propertyName: string, propertyValue: string | string[] | Record<string, string>): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addPropertyWithName = exports.removePropertyWithName = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
|
+
/**
|
|
8
|
+
* This function removes a property with a given name from an object literal
|
|
9
|
+
* provided as a text string.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} fileContent The source code as text
|
|
12
|
+
* @param {string} propertyNames The properties to remove from the object
|
|
13
|
+
*/
|
|
14
|
+
function removePropertyWithName(fileContent, ...propertyNames) {
|
|
15
|
+
const sourceFile = tsquery_1.tsquery.ast(fileContent);
|
|
16
|
+
const updatedSourceFile = tsquery_1.tsquery.map(sourceFile, "ObjectLiteralExpression", node => {
|
|
17
|
+
if (ts.isObjectLiteralExpression(node)) {
|
|
18
|
+
// Filter out the given property
|
|
19
|
+
const updatedProperties = node.properties.filter(property => {
|
|
20
|
+
return !(ts.isPropertyAssignment(property) &&
|
|
21
|
+
ts.isIdentifier(property.name) &&
|
|
22
|
+
propertyNames.includes(property.name.text));
|
|
23
|
+
});
|
|
24
|
+
return ts.factory.createObjectLiteralExpression(updatedProperties, true);
|
|
25
|
+
}
|
|
26
|
+
return node;
|
|
27
|
+
});
|
|
28
|
+
return ts.createPrinter().printFile(updatedSourceFile);
|
|
29
|
+
}
|
|
30
|
+
exports.removePropertyWithName = removePropertyWithName;
|
|
31
|
+
/**
|
|
32
|
+
* This function adds a new property with a given name and value to an object literal
|
|
33
|
+
* provided as a text string.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} fileContent - the source code as text
|
|
36
|
+
* @param {string} propertyName - the name of the property to add
|
|
37
|
+
* @param {string | string[]} propertyValue - the value of the property to add
|
|
38
|
+
*/
|
|
39
|
+
function addPropertyWithName(fileContent, propertyName, propertyValue) {
|
|
40
|
+
const sourceFile = tsquery_1.tsquery.ast(fileContent);
|
|
41
|
+
const updatedSourceFile = tsquery_1.tsquery.map(sourceFile, "ObjectLiteralExpression", node => {
|
|
42
|
+
if (ts.isObjectLiteralExpression(node)) {
|
|
43
|
+
// Add a new property to the object literal
|
|
44
|
+
let updatedProperties;
|
|
45
|
+
if (typeof propertyValue === "string") {
|
|
46
|
+
updatedProperties = [
|
|
47
|
+
...node.properties,
|
|
48
|
+
ts.factory.createPropertyAssignment(ts.factory.createIdentifier(propertyName), ts.factory.createStringLiteral(propertyValue)),
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
else if (Array.isArray(propertyValue)) {
|
|
52
|
+
const arrayLiteral = ts.factory.createArrayLiteralExpression(propertyValue.map(value => ts.factory.createStringLiteral(value)));
|
|
53
|
+
updatedProperties = [
|
|
54
|
+
...node.properties,
|
|
55
|
+
ts.factory.createPropertyAssignment(ts.factory.createIdentifier(propertyName), arrayLiteral),
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
else if (typeof propertyValue === "object") {
|
|
59
|
+
updatedProperties = [
|
|
60
|
+
...node.properties,
|
|
61
|
+
ts.factory.createPropertyAssignment(ts.factory.createIdentifier(propertyName), ts.factory.createObjectLiteralExpression(createObjectLiteralElementLike(propertyValue))),
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
return ts.factory.createObjectLiteralExpression(updatedProperties, true);
|
|
65
|
+
}
|
|
66
|
+
return node;
|
|
67
|
+
});
|
|
68
|
+
return ts.createPrinter().printFile(updatedSourceFile);
|
|
69
|
+
}
|
|
70
|
+
exports.addPropertyWithName = addPropertyWithName;
|
|
71
|
+
function createObjectLiteralElementLike(obj) {
|
|
72
|
+
const properties = [];
|
|
73
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
74
|
+
properties.push(ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(key), ts.factory.createStringLiteral(value)));
|
|
75
|
+
}
|
|
76
|
+
return properties;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=astUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astUtils.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/utils/ast/astUtils.ts"],"names":[],"mappings":";;;;AAAA,uDAAoD;AACpD,uDAAiC;AAEjC;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,WAAmB,EAAE,GAAG,aAAuB;IACpF,MAAM,UAAU,GAAG,iBAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,iBAAiB,GAAG,iBAAO,CAAC,GAAG,CAAC,UAAU,EAAE,yBAAyB,EAAE,IAAI,CAAC,EAAE;QAClF,IAAI,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE;YACtC,gCAAgC;YAChC,MAAM,iBAAiB,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;gBAC1D,OAAO,CAAC,CACN,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;oBACjC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAC9B,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAA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AAwB,CAAC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;iBAC7F,CAAC;aACH;iBAAM,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;gBAC5C,iBAAiB,GAAG;oBAClB,GAAG,IAAI,CAAC,UAAU;oBAClB,EAAE,CAAC,OAAO,CAAC,wBAAwB,CACjC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,EACzC,EAAE,CAAC,OAAO,CAAC,6BAA6B,CAAC,8BAA8B,CAAC,aAAa,CAAC,CAAC,CACxF;iBACF,CAAC;aACH;YACD,OAAO,EAAE,CAAC,OAAO,CAAC,6BAA6B,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;SAC1E;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AACzD,CAAC;AAxCD,kDAwCC;AAED,SAAS,8BAA8B,CAAC,GAA2B;IACjE,MAAM,UAAU,GAAkC,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC9C,UAAU,CAAC,IAAI,CACb,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAChH,CAAC;KACH;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import { tsquery } from \"@phenomnomnominal/tsquery\";\nimport * as ts from \"typescript\";\n\n/**\n * This function removes a property with a given name from an object literal\n * provided as a text string.\n *\n * @param {string} fileContent The source code as text\n * @param {string} propertyNames The properties to remove from the object\n */\nexport function removePropertyWithName(fileContent: string, ...propertyNames: string[]) {\n const sourceFile = tsquery.ast(fileContent);\n const updatedSourceFile = tsquery.map(sourceFile, \"ObjectLiteralExpression\", node => {\n if (ts.isObjectLiteralExpression(node)) {\n // Filter out the given property\n const updatedProperties = node.properties.filter(property => {\n return !(\n ts.isPropertyAssignment(property) &&\n ts.isIdentifier(property.name) &&\n propertyNames.includes(property.name.text)\n );\n });\n return ts.factory.createObjectLiteralExpression(updatedProperties, true);\n }\n return node;\n });\n return ts.createPrinter().printFile(updatedSourceFile);\n}\n\n/**\n * This function adds a new property with a given name and value to an object literal\n * provided as a text string.\n *\n * @param {string} fileContent - the source code as text\n * @param {string} propertyName - the name of the property to add\n * @param {string | string[]} propertyValue - the value of the property to add\n */\nexport function addPropertyWithName(\n fileContent: string,\n propertyName: string,\n propertyValue: string | string[] | Record<string, string>\n) {\n const sourceFile = tsquery.ast(fileContent);\n const updatedSourceFile = tsquery.map(sourceFile, \"ObjectLiteralExpression\", node => {\n if (ts.isObjectLiteralExpression(node)) {\n // Add a new property to the object literal\n let updatedProperties;\n if (typeof propertyValue === \"string\") {\n updatedProperties = [\n ...node.properties,\n ts.factory.createPropertyAssignment(\n ts.factory.createIdentifier(propertyName),\n ts.factory.createStringLiteral(propertyValue)\n ),\n ];\n } else if (Array.isArray(propertyValue)) {\n const arrayLiteral = ts.factory.createArrayLiteralExpression(\n propertyValue.map(value => ts.factory.createStringLiteral(value))\n );\n updatedProperties = [\n ...node.properties,\n ts.factory.createPropertyAssignment(ts.factory.createIdentifier(propertyName), arrayLiteral),\n ];\n } else if (typeof propertyValue === \"object\") {\n updatedProperties = [\n ...node.properties,\n ts.factory.createPropertyAssignment(\n ts.factory.createIdentifier(propertyName),\n ts.factory.createObjectLiteralExpression(createObjectLiteralElementLike(propertyValue))\n ),\n ];\n }\n return ts.factory.createObjectLiteralExpression(updatedProperties, true);\n }\n return node;\n });\n return ts.createPrinter().printFile(updatedSourceFile);\n}\n\nfunction createObjectLiteralElementLike(obj: Record<string, string>): ts.ObjectLiteralElementLike[] {\n const properties: ts.ObjectLiteralElementLike[] = [];\n for (const [key, value] of Object.entries(obj)) {\n properties.push(\n ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(key), ts.factory.createStringLiteral(value))\n );\n }\n return properties;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tree } from "@nrwl/devkit";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param tree File system tree
|
|
5
|
+
* @param path Path to source file in the Tree
|
|
6
|
+
* @param updater Function that maps the current file content to a new to be written to the Tree
|
|
7
|
+
*/
|
|
8
|
+
export declare const updateFileInTree: (tree: Tree, path: string, updater: (fileContent: string) => string) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateFileInTree = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param tree File system tree
|
|
7
|
+
* @param path Path to source file in the Tree
|
|
8
|
+
* @param updater Function that maps the current file content to a new to be written to the Tree
|
|
9
|
+
*/
|
|
10
|
+
const updateFileInTree = (tree, path, updater) => {
|
|
11
|
+
if (!tree.exists(path)) {
|
|
12
|
+
throw new Error("File not found: " + path);
|
|
13
|
+
}
|
|
14
|
+
const fileContent = tree.read(path, "utf-8");
|
|
15
|
+
if (!fileContent) {
|
|
16
|
+
throw new Error("File is empty: " + path);
|
|
17
|
+
}
|
|
18
|
+
const result = updater(fileContent);
|
|
19
|
+
if (result !== fileContent) {
|
|
20
|
+
tree.write(path, result);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.updateFileInTree = updateFileInTree;
|
|
24
|
+
//# sourceMappingURL=fileUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUpdater.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app/src/utils/fileUpdater.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAE,IAAY,EAAE,OAAwC,EAAE,EAAE;IACrG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;KAC5C;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;KAC3C;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpC,IAAI,MAAM,KAAK,WAAW,EAAE;QAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;KAC1B;AACH,CAAC,CAAC;AAdW,QAAA,gBAAgB,oBAc3B","sourcesContent":["import { Tree } from \"@nrwl/devkit\";\n\n/**\n *\n * @param tree File system tree\n * @param path Path to source file in the Tree\n * @param updater Function that maps the current file content to a new to be written to the Tree\n */\nexport const updateFileInTree = (tree: Tree, path: string, updater: (fileContent: string) => string) => {\n if (!tree.exists(path)) {\n throw new Error(\"File not found: \" + path);\n }\n\n const fileContent = tree.read(path, \"utf-8\");\n if (!fileContent) {\n throw new Error(\"File is empty: \" + path);\n }\n const result = updater(fileContent);\n\n if (result !== fileContent) {\n tree.write(path, result);\n }\n};\n"]}
|