@trackunit/iris-app 0.0.124 → 0.0.125
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 +7 -0
- package/package.json +4 -4
- package/src/generators/create/files/assets/description.md +2 -2
- package/src/generators/create/files/iris-app-manifest.ts__template__ +1 -1
- package/src/generators/create/files/tailwind.config.js__template__ +1 -1
- package/src/generators/create/files/tsconfig.app.json__template__ +4 -4
- package/src/generators/create/files/tsconfig.json__template__ +2 -2
- package/src/generators/create/generator.js +4 -2
- package/src/generators/create/generator.js.map +1 -1
- package/src/generators/create/schema.d.ts +1 -0
- package/src/generators/create/schema.json +9 -0
- package/src/generators/extend/generator.js +15 -0
- package/src/generators/extend/generator.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
### [0.0.125](https://github.com/Trackunit/manager/compare/iris-app/0.0.124...iris-app/0.0.125) (2022-10-27)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `iris-app-build-utilities` updated to version `0.0.1`
|
|
10
|
+
* `iris-app-api` updated to version `0.0.1`
|
|
11
|
+
* `iris-app-webpack-plugin` updated to version `0.0.1`
|
|
5
12
|
### [0.0.124](https://github.com/Trackunit/manager/compare/iris-app/0.0.123...iris-app/0.0.124) (2022-10-25)
|
|
6
13
|
|
|
7
14
|
### [0.0.123](https://github.com/Trackunit/manager/compare/iris-app/0.0.122...iris-app/0.0.123) (2022-10-24)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.125",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"generators": "./generators.json",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"echarts": "^5.4.0",
|
|
14
14
|
"penpal": "^6.2.2",
|
|
15
15
|
"babel-plugin-styled-components": "1.13.3",
|
|
16
|
-
"@trackunit/iris-app-build-utilities": "0.0.
|
|
16
|
+
"@trackunit/iris-app-build-utilities": "0.0.59",
|
|
17
17
|
"tsconfig-paths": "^3.14.1",
|
|
18
18
|
"typescript": "4.7.3",
|
|
19
|
-
"@trackunit/iris-app-api": "0.0.
|
|
19
|
+
"@trackunit/iris-app-api": "0.0.54",
|
|
20
20
|
"node-fetch": "^2.6.7",
|
|
21
21
|
"libnpmpublish": "^6.0.5",
|
|
22
22
|
"open": "^8.4.0",
|
|
23
23
|
"pacote": "^13.6.2",
|
|
24
|
-
"@trackunit/iris-app-webpack-plugin": "0.0.
|
|
24
|
+
"@trackunit/iris-app-webpack-plugin": "0.0.58",
|
|
25
25
|
"enquirer": "^2.3.6",
|
|
26
26
|
"tslib": "^2.4.0"
|
|
27
27
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
# YOUR TITLE HERE
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
YOUR DESCRIPTION HERE
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IrisAppManifest } from '@trackunit/iris-app-api';
|
|
2
2
|
|
|
3
|
-
const nxPackageJson = require("
|
|
3
|
+
const nxPackageJson = require("<%= toNxRoot %>package.json");
|
|
4
4
|
const packageJson = require("./package.json");
|
|
5
5
|
|
|
6
6
|
const IrisAppManifest: IrisAppManifest = {
|
|
@@ -4,7 +4,7 @@ const path = require("path");
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
presets: [require('@trackunit/css-tailwind/tailwind-base.generated.js')],
|
|
6
6
|
content: getTailwindContentForApp({
|
|
7
|
-
nxRootDir: path.resolve(__dirname, "
|
|
7
|
+
nxRootDir: path.resolve(__dirname, "<%= toNxRoot %>"),
|
|
8
8
|
app: "<%= projectName %>",
|
|
9
9
|
}),
|
|
10
10
|
plugins: [require("@trackunit/css-components")],
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "./tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"outDir": "
|
|
4
|
+
"outDir": "<%= toNxRoot %>dist/<%= projectName %>",
|
|
5
5
|
"types": ["node"]
|
|
6
6
|
},
|
|
7
7
|
"files": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"<%= toNxRoot %>node_modules/@nrwl/react/typings/cssmodule.d.ts",
|
|
9
|
+
"<%= toNxRoot %>node_modules/@nrwl/react/typings/image.d.ts"
|
|
10
10
|
],
|
|
11
11
|
"exclude": [
|
|
12
12
|
"test/**/*",
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"**/*.stories.jsx",
|
|
18
18
|
"**/*.stories.tsx"
|
|
19
19
|
],
|
|
20
|
-
"include": ["
|
|
20
|
+
"include": ["<%= toNxRoot %>typings", "**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
|
|
21
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "
|
|
2
|
+
"extends": "<%= toNxRoot %>tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"jsx": "react-jsx",
|
|
5
5
|
"resolveJsonModule": true,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"moduleResolution": "node",
|
|
14
14
|
},
|
|
15
15
|
"files": [],
|
|
16
|
-
"include": ["
|
|
16
|
+
"include": ["<%= toNxRoot %>typings"],
|
|
17
17
|
"references": [
|
|
18
18
|
{
|
|
19
19
|
"path": "./tsconfig.app.json"
|
|
@@ -7,8 +7,9 @@ const pacote = tslib_1.__importStar(require("pacote"));
|
|
|
7
7
|
const path = tslib_1.__importStar(require("path"));
|
|
8
8
|
function normalizeOptions(tree, options) {
|
|
9
9
|
const name = (0, devkit_1.names)(options.name).fileName;
|
|
10
|
-
const projectDirectory = name;
|
|
11
|
-
const
|
|
10
|
+
const projectDirectory = options.directory ? path.join(options.directory, name) : name;
|
|
11
|
+
const toNxRoot = `../../${projectDirectory.indexOf("/") !== -1 ? "../" : ""}`;
|
|
12
|
+
const projectName = name.replace(new RegExp("/", "g"), "_");
|
|
12
13
|
const npmScope = (0, devkit_1.getWorkspaceLayout)(tree).npmScope;
|
|
13
14
|
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${projectDirectory}`;
|
|
14
15
|
return {
|
|
@@ -16,6 +17,7 @@ function normalizeOptions(tree, options) {
|
|
|
16
17
|
projectName,
|
|
17
18
|
projectRoot,
|
|
18
19
|
projectDirectory,
|
|
20
|
+
toNxRoot,
|
|
19
21
|
npmScope,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
@@ -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;
|
|
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,CA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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;IAElC,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;AAnGW,QAAA,gBAAgB,oBAmG3B;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\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 throw new Error(\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.3.1\",\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\": \"^14.5.6\",\n \"@nrwl/workspace\": \"^14.5.6\",\n \"@nrwl/devkit\": \"^14.5.6\",\n \"@babel/preset-env\": \"^7.0.0\",\n eslint: \"^8.0.0\",\n \"ts-morph\": \"^13.0.2\",\n \"@babel/core\": \"^7.17.5\",\n \"babel-loader\": \"^8.2.3\",\n \"postcss-js\": \"^4.0.0\",\n \"postcss-loader\": \"^6.2.1\",\n \"postcss-nested\": \"^5.0.6\",\n postcss: \"^8.4.7\",\n \"style-loader\": \"^3.3.1\",\n \"json-loader\": \"^0.5.7\",\n autoprefixer: \"^10.4.2\",\n \"css-loader\": \"^6.6.0\",\n webpack: \"^5.65.0\",\n tailwindcss: \"^3.0.23\",\n \"ts-node\": \"^10.4.0\",\n \"webpack-dev-server\": \"4.7.3\",\n \"webpack-cli\": \"^4.9.1\",\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\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n };\n};\n\nexport default IrisAppGenerator;\n"]}
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
},
|
|
15
15
|
"x-prompt": "What name would you like to use for this app?"
|
|
16
16
|
},
|
|
17
|
+
"directory": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "What subdir would you like to use for this app",
|
|
20
|
+
"alias": "d",
|
|
21
|
+
"$default": {
|
|
22
|
+
"$source": "argv",
|
|
23
|
+
"index": 1
|
|
24
|
+
}
|
|
25
|
+
},
|
|
17
26
|
"updatePackageJson": {
|
|
18
27
|
"type": "boolean",
|
|
19
28
|
"description": "If the package.json should be updated with required dependencies",
|
|
@@ -117,6 +117,21 @@ const updateAppName = async (tree, options) => {
|
|
|
117
117
|
if (irisAppManifest) {
|
|
118
118
|
tileApps.push(folder.name);
|
|
119
119
|
}
|
|
120
|
+
else {
|
|
121
|
+
const subFolders = fs
|
|
122
|
+
.readdirSync(path.join((0, devkit_1.getWorkspaceLayout)(tree).appsDir, folder.name), { withFileTypes: true })
|
|
123
|
+
.filter(item => item.isDirectory());
|
|
124
|
+
subFolders.forEach(subFolder => {
|
|
125
|
+
const subDirIrisAppManifest = fs
|
|
126
|
+
.readdirSync(`${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${folder.name}/${subFolder.name}`, {
|
|
127
|
+
withFileTypes: true,
|
|
128
|
+
})
|
|
129
|
+
.find(item => item.name === "iris-app-manifest.ts");
|
|
130
|
+
if (subDirIrisAppManifest) {
|
|
131
|
+
tileApps.push(path.join(folder.name, subFolder.name));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
120
135
|
});
|
|
121
136
|
if (tileApps.length === 1) {
|
|
122
137
|
options.app = tileApps[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/extend/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAUsB;AACtB,yCAAsC;AACtC,uCAA+C;AAE/C,yEAAqF;AACrF,kEAAkC;AAClC,2DAAqC;AACrC,+CAAyB;AACzB,mDAA6B;AAC7B,uCAAqD;AAYrD,SAAS,gBAAgB,CAAC,IAAU,EAAE,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,CAAC,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC3B;aAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;SACnF;aAAM;YACL,MAAM,MAAM,GAAG;gBACb,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,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE;gBACpD,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 names,\n offsetFromRoot,\n Tree,\n updateJson,\n} from \"@nrwl/devkit\";\nimport { Linter } from \"@nrwl/linter\";\nimport { libraryGenerator } from \"@nrwl/react\";\nimport { Schema } from \"@nrwl/react/src/generators/library/schema\";\nimport { getRootTsConfigPathInTree } from \"@nrwl/workspace/src/utilities/typescript\";\nimport camelcase from \"camelcase\";\nimport * as Enquirer from \"enquirer\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { Node, Project, SyntaxKind } from \"ts-morph\";\nimport { IrisAppExtensionGeneratorSchema } from \"./schema\";\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\nexport const IrisAppExtensionGenerator = async function (tree: Tree, schemaOptions: IrisAppExtensionGeneratorSchema) {\n const options = await updateAppName(tree, schemaOptions);\n\n const normalizedOptions = normalizeOptions(tree, options);\n\n const templateOptions = {\n ...normalizedOptions,\n ...names(options.name),\n offsetFromRoot: offsetFromRoot(normalizedOptions.projectRoot),\n template: \"\",\n };\n const irisAppExtensionType = options.type;\n\n if (!fs.existsSync(`${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 (!fs.existsSync(manifestPath)) {\n throw `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 generateFiles(\n tree,\n path.join(__dirname, \"files\", irisAppExtensionType),\n normalizedOptions.projectRoot,\n templateOptions\n );\n\n if (options.updatePackageJson) {\n addDependenciesToPackageJson(\n tree,\n {},\n {\n \"single-spa\": \"^5.9.3\",\n \"single-spa-react\": \"^4.6.1\",\n }\n );\n }\n\n const schema: Schema = {\n name: options.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: options.directory,\n skipTsConfig: false,\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 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 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 }\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 prompt = {\n name: \"app\",\n message: \"Select iris-app for this extension:\",\n type: \"select\",\n choices: tileApps.map(item => item),\n };\n await Enquirer.prompt(prompt).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,yCAUsB;AACtB,yCAAsC;AACtC,uCAA+C;AAE/C,yEAAqF;AACrF,kEAAkC;AAClC,2DAAqC;AACrC,+CAAyB;AACzB,mDAA6B;AAC7B,uCAAqD;AAYrD,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,Q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D,IAAI,qBAAqB,EAAE;wBACzB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;qBACvD;gBACH,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC3B;aAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;SACnF;aAAM;YACL,MAAM,MAAM,GAAG;gBACb,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,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE;gBACpD,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 names,\n offsetFromRoot,\n Tree,\n updateJson,\n} from \"@nrwl/devkit\";\nimport { Linter } from \"@nrwl/linter\";\nimport { libraryGenerator } from \"@nrwl/react\";\nimport { Schema } from \"@nrwl/react/src/generators/library/schema\";\nimport { getRootTsConfigPathInTree } from \"@nrwl/workspace/src/utilities/typescript\";\nimport camelcase from \"camelcase\";\nimport * as Enquirer from \"enquirer\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { Node, Project, SyntaxKind } from \"ts-morph\";\nimport { IrisAppExtensionGeneratorSchema } from \"./schema\";\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\nexport const IrisAppExtensionGenerator = async function (tree: Tree, schemaOptions: IrisAppExtensionGeneratorSchema) {\n const options = await updateAppName(tree, schemaOptions);\n\n const normalizedOptions = normalizeOptions(tree, options);\n\n const templateOptions = {\n ...normalizedOptions,\n ...names(options.name),\n offsetFromRoot: offsetFromRoot(normalizedOptions.projectRoot),\n template: \"\",\n };\n const irisAppExtensionType = options.type;\n\n if (!fs.existsSync(`${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 (!fs.existsSync(manifestPath)) {\n throw `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 generateFiles(\n tree,\n path.join(__dirname, \"files\", irisAppExtensionType),\n normalizedOptions.projectRoot,\n templateOptions\n );\n\n if (options.updatePackageJson) {\n addDependenciesToPackageJson(\n tree,\n {},\n {\n \"single-spa\": \"^5.9.3\",\n \"single-spa-react\": \"^4.6.1\",\n }\n );\n }\n\n const schema: Schema = {\n name: options.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: options.directory,\n skipTsConfig: false,\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 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 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 prompt = {\n name: \"app\",\n message: \"Select iris-app for this extension:\",\n type: \"select\",\n choices: tileApps.map(item => item),\n };\n await Enquirer.prompt(prompt).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"]}
|