@trackunit/iris-app 1.3.121 → 1.3.123
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 +20 -0
- package/package.json +6 -6
- package/src/generators/extend/files/AI_AGENT_EXTENSION/extension-manifest.ts__template__ +4 -4
- package/src/generators/extend/files/AI_AGENT_EXTENSION/src/index.ts__template__ +13 -66
- package/src/generators/extend/files/SERVERLESS_FUNCTION_EXTENSION/extension-manifest.ts__template__ +4 -4
- package/src/generators/extend/generator.js +42 -6
- package/src/generators/extend/generator.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 1.3.123 (2025-05-22)
|
|
2
|
+
|
|
3
|
+
### 🧱 Updated Dependencies
|
|
4
|
+
|
|
5
|
+
- Updated iris-app-build-utilities to 1.3.121
|
|
6
|
+
- Updated iris-app-webpack-plugin to 1.3.121
|
|
7
|
+
- Updated iris-app-api to 1.3.121
|
|
8
|
+
- Updated react-test-setup to 1.0.6
|
|
9
|
+
- Updated shared-utils to 1.5.116
|
|
10
|
+
|
|
11
|
+
## 1.3.122 (2025-05-22)
|
|
12
|
+
|
|
13
|
+
### 🧱 Updated Dependencies
|
|
14
|
+
|
|
15
|
+
- Updated iris-app-build-utilities to 1.3.120
|
|
16
|
+
- Updated iris-app-webpack-plugin to 1.3.120
|
|
17
|
+
- Updated iris-app-api to 1.3.120
|
|
18
|
+
- Updated react-test-setup to 1.0.5
|
|
19
|
+
- Updated shared-utils to 1.5.115
|
|
20
|
+
|
|
1
21
|
## 1.3.121 (2025-05-21)
|
|
2
22
|
|
|
3
23
|
### 🧱 Updated Dependencies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.123",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"generators": "./generators.json",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@npmcli/arborist": "^7.3.1",
|
|
33
33
|
"webpack-bundle-analyzer": "^4.8.0",
|
|
34
34
|
"win-ca": "^3.5.1",
|
|
35
|
-
"@trackunit/iris-app-build-utilities": "1.3.
|
|
36
|
-
"@trackunit/shared-utils": "1.5.
|
|
37
|
-
"@trackunit/iris-app-api": "1.3.
|
|
38
|
-
"@trackunit/iris-app-webpack-plugin": "1.3.
|
|
35
|
+
"@trackunit/iris-app-build-utilities": "1.3.121",
|
|
36
|
+
"@trackunit/shared-utils": "1.5.116",
|
|
37
|
+
"@trackunit/iris-app-api": "1.3.121",
|
|
38
|
+
"@trackunit/iris-app-webpack-plugin": "1.3.121",
|
|
39
39
|
"tslib": "^2.6.2",
|
|
40
|
-
"@trackunit/react-test-setup": "1.0.
|
|
40
|
+
"@trackunit/react-test-setup": "1.0.6"
|
|
41
41
|
},
|
|
42
42
|
"types": "./src/index.d.ts",
|
|
43
43
|
"type": "commonjs"
|
|
@@ -4,10 +4,10 @@ const aiAgentExtensionManifest: AiAgentExtensionManifest = {
|
|
|
4
4
|
id: "<%= projectName %>",
|
|
5
5
|
type: "AI_AGENT_EXTENSION",
|
|
6
6
|
runtime: "DENO",
|
|
7
|
-
sourceRoot: "
|
|
8
|
-
dependencyDefinitionFile: "
|
|
9
|
-
name: "
|
|
10
|
-
main: "index.
|
|
7
|
+
sourceRoot: "dist/<%= projectRoot %>/",
|
|
8
|
+
dependencyDefinitionFile: "dist/<%= dependencyDefinitionFile %>",
|
|
9
|
+
name: "AI Agent <%= projectName %>",
|
|
10
|
+
main: "index.js",
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export default aiAgentExtensionManifest;
|
|
@@ -1,81 +1,28 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import {
|
|
2
|
+
import { streamText } from "ai";
|
|
3
3
|
import cors from "cors";
|
|
4
4
|
import express, { Request, Response } from "express";
|
|
5
5
|
|
|
6
|
-
// Log the current working directory
|
|
7
|
-
console.log("Current working directory:", Deno.cwd());
|
|
8
|
-
|
|
9
6
|
const app = express();
|
|
10
7
|
app.use(cors());
|
|
11
8
|
app.use(express.json());
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
app.get("/test", (req: Request, res: Response) => {
|
|
11
|
+
res.send("Test success.");
|
|
15
12
|
});
|
|
16
13
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
You should:
|
|
22
|
-
- Provide concise, professional responses focused on construction equipment and fleet management
|
|
23
|
-
- Understand common construction industry terminology and workflows
|
|
24
|
-
- Help users analyze equipment data, troubleshoot issues, and optimize fleet operations
|
|
25
|
-
- Offer actionable insights that improve productivity and reduce downtime
|
|
26
|
-
- Respect data privacy and security at all times
|
|
27
|
-
|
|
28
|
-
When discussing equipment:
|
|
29
|
-
- Focus on maintenance schedules, utilization rates, and performance metrics
|
|
30
|
-
- Help interpret fault codes and suggest potential solutions
|
|
31
|
-
- Provide context about industry standards and best practices
|
|
32
|
-
|
|
33
|
-
Users might refer to construction equipment as assets, in that case it could be machines, vehicles, or other equipment like tools.
|
|
34
|
-
|
|
35
|
-
If you're uncertain about something, acknowledge your limitations and suggest where the user might find more information.
|
|
36
|
-
|
|
37
|
-
Always prioritize safety and compliance in your recommendations.`,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const handleRequest = async (req: Request, res: Response, useStream: boolean) => {
|
|
41
|
-
try {
|
|
42
|
-
// Validate the request body against the coreMessageSchema
|
|
43
|
-
const parseResult = coreMessageSchema.array().safeParse(req.body.messages);
|
|
44
|
-
|
|
45
|
-
if (!parseResult.success) {
|
|
46
|
-
return res.status(400).json({
|
|
47
|
-
error: "Invalid message format",
|
|
48
|
-
details: parseResult.error.format(),
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const messages = parseResult.data;
|
|
53
|
-
|
|
54
|
-
if (useStream) {
|
|
55
|
-
const streamResult = streamText({
|
|
56
|
-
...defaultAgentConfig,
|
|
57
|
-
messages,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return streamResult.pipeDataStreamToResponse(res, {
|
|
61
|
-
sendReasoning: true,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
14
|
+
const openai = createOpenAI({
|
|
15
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
16
|
+
});
|
|
64
17
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} catch (error) {
|
|
71
|
-
if (!res.headersSent) {
|
|
72
|
-
res.status(500).json({ error: "Internal server error" });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
18
|
+
app.post("/", async (req: Request, res: Response) => {
|
|
19
|
+
const result = streamText({
|
|
20
|
+
model: openai("gpt-4o"),
|
|
21
|
+
prompt: "Invent a new holiday and describe its traditions.",
|
|
22
|
+
});
|
|
76
23
|
|
|
77
|
-
|
|
78
|
-
|
|
24
|
+
result.pipeDataStreamToResponse(res);
|
|
25
|
+
});
|
|
79
26
|
|
|
80
27
|
const port = process.env.PORT || 8000;
|
|
81
28
|
app.listen(port);
|
package/src/generators/extend/files/SERVERLESS_FUNCTION_EXTENSION/extension-manifest.ts__template__
CHANGED
|
@@ -4,10 +4,10 @@ const serverlessFunctionExtensionManifest: ServerlessFunctionExtensionManifest =
|
|
|
4
4
|
id: "<%= projectName %>",
|
|
5
5
|
type: "SERVERLESS_FUNCTION_EXTENSION",
|
|
6
6
|
runtime: "DENO",
|
|
7
|
-
sourceRoot: "
|
|
8
|
-
dependencyDefinitionFile: "
|
|
9
|
-
name: "
|
|
10
|
-
main: "index.
|
|
7
|
+
sourceRoot: "dist/<%= projectRoot %>/",
|
|
8
|
+
dependencyDefinitionFile: "dist/<%= dependencyDefinitionFile %>",
|
|
9
|
+
name: "Serverless Function <%= projectName %>",
|
|
10
|
+
main: "index.js",
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export default serverlessFunctionExtensionManifest;
|
|
@@ -97,10 +97,8 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
97
97
|
if (iris_app_api_1.serverSideExtensionTypes.includes(irisAppExtensionType)) {
|
|
98
98
|
tsConfigBase.compilerOptions = {
|
|
99
99
|
...tsConfigBase.compilerOptions,
|
|
100
|
-
types: ["
|
|
101
|
-
|
|
102
|
-
emitDeclarationOnly: true,
|
|
103
|
-
declaration: true,
|
|
100
|
+
types: ["node"],
|
|
101
|
+
esModuleInterop: true,
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
104
|
tsConfigBase.compilerOptions.paths[normalizedOptions.importPath] = [
|
|
@@ -112,9 +110,47 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
112
110
|
if (iris_app_api_1.serverSideExtensionTypes.includes(irisAppExtensionType)) {
|
|
113
111
|
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(normalizedOptions.projectRoot, "project.json"), projectJson => {
|
|
114
112
|
projectJson.targets.serve = {
|
|
115
|
-
executor: "nx:
|
|
113
|
+
executor: "@nx/js:node",
|
|
116
114
|
options: {
|
|
117
|
-
|
|
115
|
+
buildTarget: `${normalizedOptions.projectName}:build`,
|
|
116
|
+
inspect: true,
|
|
117
|
+
},
|
|
118
|
+
configurations: {
|
|
119
|
+
breakOnStart: {
|
|
120
|
+
inspect: "inspect-brk",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
projectJson.targets.build = {
|
|
125
|
+
executor: "@nx/esbuild:esbuild",
|
|
126
|
+
outputs: ["{options.outputPath}"],
|
|
127
|
+
defaultConfiguration: "production",
|
|
128
|
+
options: {
|
|
129
|
+
platform: "node",
|
|
130
|
+
outputPath: `dist/${normalizedOptions.projectRoot}`,
|
|
131
|
+
format: ["cjs"],
|
|
132
|
+
bundle: true,
|
|
133
|
+
thirdParty: true,
|
|
134
|
+
external: [],
|
|
135
|
+
main: `${normalizedOptions.sourceRoot}/index.ts`,
|
|
136
|
+
tsConfig: `libs/${normalizedOptions.projectDirectory}/tsconfig.lib.json`,
|
|
137
|
+
esbuildOptions: {
|
|
138
|
+
sourcemap: true,
|
|
139
|
+
outExtension: {
|
|
140
|
+
".js": ".js",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
configurations: {
|
|
144
|
+
development: {},
|
|
145
|
+
production: {
|
|
146
|
+
esbuildOptions: {
|
|
147
|
+
sourcemap: false,
|
|
148
|
+
outExtension: {
|
|
149
|
+
".js": ".js",
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
118
154
|
},
|
|
119
155
|
};
|
|
120
156
|
return projectJson;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/extend/generator.ts"],"names":[],"mappings":";;;;AAAA,uCAWoB;AACpB,uCAAoC;AACpC,+BAAmD;AACnD,+EAA0E;AAC1E,qCAA6C;AAE7C,0DAAwF;AACxF,uCAAkC;AAClC,+CAAyB;AACzB,mDAA6B;AAC7B,yCAAsC;AACtC,uCAAoE;AACpE,uDAA+D;AAC/D,yDAA2D;AAC3D,iDAAmE;AAanE,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,M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CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;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 \"@nx/devkit\";\nimport { Linter } from \"@nx/eslint\";\nimport { getRootTsConfigPathInTree } from \"@nx/js\";\nimport { getNpmScope } from \"@nx/js/src/utils/package-json/get-npm-scope\";\nimport { libraryGenerator } from \"@nx/react\";\nimport { Schema } from \"@nx/react/src/generators/library/schema\";\nimport { nonUiExtensionTypes, serverSideExtensionTypes } from \"@trackunit/iris-app-api\";\nimport { prompt } from \"enquirer\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { camelCase } from \"string-ts\";\nimport { Project, SyntaxKind, VariableDeclaration } from \"ts-morph\";\nimport { addPropertyWithName } from \"../../utils/ast/astUtils\";\nimport { updateFileInTree } from \"../../utils/fileUpdater\";\nimport { spaDependencies, testDependencies } from \"./dependencies\";\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 dependencyDefinitionFile: 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(projectName);\n const wsLayout = getWorkspaceLayout(tree);\n const projectRoot = `${wsLayout.libsDir}/${projectDirectory}`;\n const sourceRoot = `${wsLayout.libsDir}/${projectDirectory}/src`;\n const dependencyDefinitionFile = `${wsLayout.libsDir}/${projectDirectory}/package.json`;\n\n const npmScope = getNpmScope(tree);\n if (!npmScope) {\n throw new Error(\"Could not find npm scope in package.json\");\n }\n const importPath = `@${npmScope}/${projectName}`;\n\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n projectCamelcase,\n importPath,\n sourceRoot,\n dependencyDefinitionFile,\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\n if (normalizedOptions.updatePackageJson) {\n addDependenciesToPackageJson(\n tree,\n {},\n {\n ...spaDependencies,\n ...testDependencies,\n }\n );\n }\n\n const schema: Schema = {\n name: normalizedOptions.projectName,\n style: \"none\",\n skipFormat: false,\n strict: true,\n unitTestRunner: \"jest\",\n linter: Linter.EsLint,\n routing: false,\n directory: normalizedOptions.projectRoot,\n skipTsConfig: false,\n skipPackageJson: true,\n };\n\n await libraryGenerator(tree, schema);\n\n generateFiles(\n tree,\n path.join(__dirname, \"files\", irisAppExtensionType),\n normalizedOptions.projectRoot,\n templateOptions\n );\n\n if (!nonUiExtensionTypes.includes(irisAppExtensionType)) {\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 // For server side extension types, we need to add deno types to the tsconfig and make Typescript accept Deno import syntax\n if (serverSideExtensionTypes.includes(irisAppExtensionType)) {\n tsConfigBase.compilerOptions = {\n ...tsConfigBase.compilerOptions,\n types: [\"deno\"],\n allowImportingTsExtensions: true,\n emitDeclarationOnly: true,\n declaration: true,\n };\n }\n\n tsConfigBase.compilerOptions.paths[normalizedOptions.importPath] = [\n path.join(normalizedOptions.projectRoot, \"extension-manifest.ts\"),\n ];\n return tsConfigBase;\n });\n\n // Add working serve target to the project.json for DENO extensions\n if (serverSideExtensionTypes.includes(irisAppExtensionType)) {\n updateJson(tree, joinPathFragments(normalizedOptions.projectRoot, \"project.json\"), projectJson => {\n projectJson.targets.serve = {\n executor: \"nx:run-commands\",\n options: {\n command: `deno run --env-file=libs/${normalizedOptions.projectDirectory}/.env --allow-env --allow-net --allow-read ${normalizedOptions.sourceRoot}/index.ts`,\n },\n };\n return projectJson;\n });\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 // Get the default export symbol from the manifest\n const defaultExportSymbol = manifest.getDefaultExportSymbolOrThrow();\n\n // Get the aliased symbol if the default export is an alias\n const aliasedSymbol = defaultExportSymbol.getAliasedSymbol() || defaultExportSymbol;\n\n // Get the declaration of the aliased symbol\n const declaration = aliasedSymbol.getDeclarations()[0];\n\n if (!VariableDeclaration.isVariableDeclaration(declaration)) {\n throw new Error(\"Expected variable declaration\");\n }\n const irisAppManifestObject = declaration.getInitializer()?.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n if (!irisAppManifestObject) {\n throw new Error(`irisAppManifest not exported from the file: ${manifestPath}`);\n }\n // Find the extensions property within the irisAppManifest object\n const extensionsProperty = irisAppManifestObject.getPropertyOrThrow(\"extensions\");\n\n if (extensionsProperty.getKind() === SyntaxKind.PropertyAssignment) {\n const extensionsArray = extensionsProperty.getFirstChildByKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n extensionsArray.addElement(`${normalizedOptions.projectCamelcase}`);\n }\n\n await manifest.save();\n\n if (!serverSideExtensionTypes.includes(irisAppExtensionType)) {\n tree.delete(joinPathFragments(normalizedOptions.projectRoot, \"src\", \"index.ts\"));\n }\n\n updateJson(tree, joinPathFragments(normalizedOptions.projectRoot, \"tsconfig.spec.json\"), tsConfigSpec => {\n // extension-manifest.ts is a build time file, so we only need to include it in the spec file for type/lint checking\n tsConfigSpec.include = [...tsConfigSpec.include, \"extension-manifest.ts\"];\n return tsConfigSpec;\n });\n\n updateFileInTree(tree, joinPathFragments(normalizedOptions.projectRoot, \"jest.config.ts\"), fileContent =>\n addPropertyWithName(fileContent, \"moduleNameMapper\", {\n \"@trackunit/css-core\": \"jest-transform-stub\",\n \"@trackunit/ui-icons/icons-sprite-mini.svg\": \"jest-transform-stub\",\n \"@trackunit/ui-icons/icons-sprite-outline.svg\": \"jest-transform-stub\",\n \"@trackunit/ui-icons/icons-sprite-solid.svg\": \"jest-transform-stub\",\n \"@trackunit/ui-icons/icons-sprite-micro.svg\": \"jest-transform-stub\",\n })\n );\n\n await formatFiles(tree);\n installPackagesTask(tree, true);\n return () => {\n // eslint-disable-next-line no-console\n console.log(\"🥳 Successfully created an app extensions and it is already added to the Iris App!\");\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] || \"<Missing iris app name>\";\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 the iris app that this extension should belong to:\",\n type: \"autocomplete\",\n choices: tileApps.map(item => item),\n };\n await prompt(promptObject).then((values: object) => {\n // @ts-ignore - suppressImplicitAnyIndexErrors\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,uCAWoB;AACpB,uCAAoC;AACpC,+BAAmD;AACnD,+EAA0E;AAC1E,qCAA6C;AAE7C,0DAAwF;AACxF,uCAAkC;AAClC,+CAAyB;AACzB,mDAA6B;AAC7B,yCAAsC;AACtC,uCAAoE;AACpE,uDAA+D;AAC/D,y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C;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 \"@nx/devkit\";\nimport { Linter } from \"@nx/eslint\";\nimport { getRootTsConfigPathInTree } from \"@nx/js\";\nimport { getNpmScope } from \"@nx/js/src/utils/package-json/get-npm-scope\";\nimport { libraryGenerator } from \"@nx/react\";\nimport { Schema } from \"@nx/react/src/generators/library/schema\";\nimport { nonUiExtensionTypes, serverSideExtensionTypes } from \"@trackunit/iris-app-api\";\nimport { prompt } from \"enquirer\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { camelCase } from \"string-ts\";\nimport { Project, SyntaxKind, VariableDeclaration } from \"ts-morph\";\nimport { addPropertyWithName } from \"../../utils/ast/astUtils\";\nimport { updateFileInTree } from \"../../utils/fileUpdater\";\nimport { spaDependencies, testDependencies } from \"./dependencies\";\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 dependencyDefinitionFile: 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(projectName);\n const wsLayout = getWorkspaceLayout(tree);\n const projectRoot = `${wsLayout.libsDir}/${projectDirectory}`;\n const sourceRoot = `${wsLayout.libsDir}/${projectDirectory}/src`;\n const dependencyDefinitionFile = `${wsLayout.libsDir}/${projectDirectory}/package.json`;\n\n const npmScope = getNpmScope(tree);\n if (!npmScope) {\n throw new Error(\"Could not find npm scope in package.json\");\n }\n const importPath = `@${npmScope}/${projectName}`;\n\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n projectCamelcase,\n importPath,\n sourceRoot,\n dependencyDefinitionFile,\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\n if (normalizedOptions.updatePackageJson) {\n addDependenciesToPackageJson(\n tree,\n {},\n {\n ...spaDependencies,\n ...testDependencies,\n }\n );\n }\n\n const schema: Schema = {\n name: normalizedOptions.projectName,\n style: \"none\",\n skipFormat: false,\n strict: true,\n unitTestRunner: \"jest\",\n linter: Linter.EsLint,\n routing: false,\n directory: normalizedOptions.projectRoot,\n skipTsConfig: false,\n skipPackageJson: true,\n };\n\n await libraryGenerator(tree, schema);\n\n generateFiles(\n tree,\n path.join(__dirname, \"files\", irisAppExtensionType),\n normalizedOptions.projectRoot,\n templateOptions\n );\n\n if (!nonUiExtensionTypes.includes(irisAppExtensionType)) {\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 // For server side extension types, we need to add deno types to the tsconfig and make Typescript accept Deno import syntax\n if (serverSideExtensionTypes.includes(irisAppExtensionType)) {\n tsConfigBase.compilerOptions = {\n ...tsConfigBase.compilerOptions,\n types: [\"node\"],\n esModuleInterop: true,\n };\n }\n\n tsConfigBase.compilerOptions.paths[normalizedOptions.importPath] = [\n path.join(normalizedOptions.projectRoot, \"extension-manifest.ts\"),\n ];\n return tsConfigBase;\n });\n\n // Add working serve target to the project.json for DENO extensions\n if (serverSideExtensionTypes.includes(irisAppExtensionType)) {\n updateJson(tree, joinPathFragments(normalizedOptions.projectRoot, \"project.json\"), projectJson => {\n projectJson.targets.serve = {\n executor: \"@nx/js:node\",\n options: {\n buildTarget: `${normalizedOptions.projectName}:build`,\n inspect: true,\n },\n configurations: {\n breakOnStart: {\n inspect: \"inspect-brk\",\n },\n },\n };\n projectJson.targets.build = {\n executor: \"@nx/esbuild:esbuild\",\n outputs: [\"{options.outputPath}\"],\n defaultConfiguration: \"production\",\n options: {\n platform: \"node\",\n outputPath: `dist/${normalizedOptions.projectRoot}`,\n format: [\"cjs\"],\n bundle: true,\n thirdParty: true,\n external: [],\n main: `${normalizedOptions.sourceRoot}/index.ts`,\n tsConfig: `libs/${normalizedOptions.projectDirectory}/tsconfig.lib.json`,\n esbuildOptions: {\n sourcemap: true,\n outExtension: {\n \".js\": \".js\",\n },\n },\n configurations: {\n development: {},\n production: {\n esbuildOptions: {\n sourcemap: false,\n outExtension: {\n \".js\": \".js\",\n },\n },\n },\n },\n },\n };\n return projectJson;\n });\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 // Get the default export symbol from the manifest\n const defaultExportSymbol = manifest.getDefaultExportSymbolOrThrow();\n\n // Get the aliased symbol if the default export is an alias\n const aliasedSymbol = defaultExportSymbol.getAliasedSymbol() || defaultExportSymbol;\n\n // Get the declaration of the aliased symbol\n const declaration = aliasedSymbol.getDeclarations()[0];\n\n if (!VariableDeclaration.isVariableDeclaration(declaration)) {\n throw new Error(\"Expected variable declaration\");\n }\n const irisAppManifestObject = declaration.getInitializer()?.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n if (!irisAppManifestObject) {\n throw new Error(`irisAppManifest not exported from the file: ${manifestPath}`);\n }\n // Find the extensions property within the irisAppManifest object\n const extensionsProperty = irisAppManifestObject.getPropertyOrThrow(\"extensions\");\n\n if (extensionsProperty.getKind() === SyntaxKind.PropertyAssignment) {\n const extensionsArray = extensionsProperty.getFirstChildByKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n extensionsArray.addElement(`${normalizedOptions.projectCamelcase}`);\n }\n\n await manifest.save();\n\n if (!serverSideExtensionTypes.includes(irisAppExtensionType)) {\n tree.delete(joinPathFragments(normalizedOptions.projectRoot, \"src\", \"index.ts\"));\n }\n\n updateJson(tree, joinPathFragments(normalizedOptions.projectRoot, \"tsconfig.spec.json\"), tsConfigSpec => {\n // extension-manifest.ts is a build time file, so we only need to include it in the spec file for type/lint checking\n tsConfigSpec.include = [...tsConfigSpec.include, \"extension-manifest.ts\"];\n return tsConfigSpec;\n });\n\n updateFileInTree(tree, joinPathFragments(normalizedOptions.projectRoot, \"jest.config.ts\"), fileContent =>\n addPropertyWithName(fileContent, \"moduleNameMapper\", {\n \"@trackunit/css-core\": \"jest-transform-stub\",\n \"@trackunit/ui-icons/icons-sprite-mini.svg\": \"jest-transform-stub\",\n \"@trackunit/ui-icons/icons-sprite-outline.svg\": \"jest-transform-stub\",\n \"@trackunit/ui-icons/icons-sprite-solid.svg\": \"jest-transform-stub\",\n \"@trackunit/ui-icons/icons-sprite-micro.svg\": \"jest-transform-stub\",\n })\n );\n\n await formatFiles(tree);\n installPackagesTask(tree, true);\n return () => {\n // eslint-disable-next-line no-console\n console.log(\"🥳 Successfully created an app extensions and it is already added to the Iris App!\");\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] || \"<Missing iris app name>\";\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 the iris app that this extension should belong to:\",\n type: \"autocomplete\",\n choices: tileApps.map(item => item),\n };\n await prompt(promptObject).then((values: object) => {\n // @ts-ignore - suppressImplicitAnyIndexErrors\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"]}
|