@trackunit/iris-app 2.16.14 → 2.16.16
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 +15 -0
- package/migrations/entry.js.map +1 -0
- package/migrations/p-content-space-codemod/invent-content-space.js.map +1 -0
- package/migrations/p-content-space-codemod/orchestrator.js.map +1 -0
- package/migrations/p-content-space-codemod/remove-redundant-padding.js.map +1 -0
- package/migrations/p-content-space-codemod/report-run-messaging.js.map +1 -0
- package/migrations/p-content-space-codemod/report-unresolved.js.map +1 -0
- package/migrations/p-content-space-codemod/resolve-content-shell.js.map +1 -0
- package/migrations/p-content-space-codemod/rewrite-page-content.js.map +1 -0
- package/migrations/p-content-space-codemod/shell-skip-reason.js.map +1 -0
- package/migrations/repair-tsconfig/repair-tsconfig.js +205 -0
- package/migrations/repair-tsconfig/repair-tsconfig.js.map +1 -0
- package/migrations/utils/classname-ast-rewrite.js.map +1 -0
- package/migrations/utils/resolve-extension-types.js.map +1 -0
- package/migrations.json +5 -0
- package/package.json +20 -6
- package/src/executors/submit/executor.js.map +1 -0
- package/src/executors/unpublish/executor.js.map +1 -0
- package/src/executors/utils/authentication.js.map +1 -0
- package/src/executors/utils/irisAppServerSettings.js.map +1 -0
- package/src/executors/utils/src/index.js.map +1 -0
- package/src/generators/ai-agent-sync/generator.js.map +1 -0
- package/src/generators/create/files/tsconfig.app.json__template__ +1 -0
- package/src/generators/create/generator.js +13 -21
- package/src/generators/create/generator.js.map +1 -0
- package/src/generators/extend/dependencies.js.map +1 -0
- package/src/generators/extend/generator.js +26 -34
- package/src/generators/extend/generator.js.map +1 -0
- package/src/generators/preset/generator.js +3 -7
- package/src/generators/preset/generator.js.map +1 -0
- package/src/generators/utils/get-package-manifest.js.map +1 -0
- package/src/generators/utils/link-claude-skills.js.map +1 -0
- package/src/generators/utils/own-package-json/own-package-json.d.ts +14 -0
- package/src/generators/utils/own-package-json/own-package-json.js +29 -0
- package/src/generators/utils/own-package-json/own-package-json.js.map +1 -0
- package/src/generators/utils/pinned-versions/pinned-versions.d.ts +30 -0
- package/src/generators/utils/pinned-versions/pinned-versions.js +45 -0
- package/src/generators/utils/pinned-versions/pinned-versions.js.map +1 -0
- package/src/generators/utils/uses-trackunit-eslint-plugin.js.map +1 -0
- package/src/generators/utils/write-trackunit-project-eslint-config.js.map +1 -0
- package/src/index.js.map +1 -0
- package/src/utils/ast/astUtils.js.map +1 -0
- package/src/utils/fileUpdater.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair-tsconfig.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app/migrations/repair-tsconfig/repair-tsconfig.ts"],"names":[],"mappings":";;;AAAA,uCAAoH;AACpH,+BAA0F;AAC1F,mHAAmH;AACnH,8CAA4D;AAC5D,2CAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AACxD,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AACtD,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAC9C,MAAM,SAAS,GAAG,WAAW,CAAC;AAI9B,iHAAiH;AACjH,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAuB,EAAE,CACvD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,MAAM,YAAY,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAE1G,6HAA6H;AAC7H,MAAM,cAAc,GAAG,CAAC,IAAU,EAAE,QAAgB,EAA0B,EAAE;IAC9E,MAAM,MAAM,GAAY,IAAA,iBAAQ,EAAC,IAAI,EAAE,QAAQ,CAAC,CAA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,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAM,CAAC,IAAI,CAAC,0BAA0B,OAAO,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AARW,QAAA,gBAAgB,oBAQ3B;AAEF;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,IAAU,EAAQ,EAAE;IACjD,IAAA,4BAAoB,EAAC,IAAI,CAAC,CAAC;IAC3B,IAAA,wBAAgB,EAAC,IAAI,CAAC,CAAC;AACzB,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB;AAEF,kBAAe,sBAAc,CAAC","sourcesContent":["import { getProjects, joinPathFragments, logger, normalizePath, readJson, updateJson, type Tree } from \"@nx/devkit\";\nimport { extendsResolutionFailed, getRootTsConfigPathInTree, readTsConfig } from \"@nx/js\";\n// An internal entry point: safe only because iris-app pins @nx/js exactly. Check this export on every @nx/js bump.\nimport { createTreeParseConfigHost } from \"@nx/js/internal\";\nimport { isExternalModuleNameRelative } from \"typescript\";\n\n/**\n * Repairs the TypeScript configuration of workspaces the SDK itself left\n * unbuildable under a type-checked `nx build` (SDK-649).\n *\n * Root cause (path aliases): the `extend` generator wrote `tsconfig.base.json` `paths` entries\n * without a leading `./` while the workspace preset leaves `baseUrl` unset, and\n * TypeScript 6 rejects that combination with TS5090. Generators fixed in the\n * SDK only help new workspaces, so existing ones are repaired here.\n *\n * Root cause (jsx): `iris-app:create` generated a `tsconfig.app.json` with no\n * `jsx`, so once an extension manifest imports `./src/routeTree` (`.tsx`) the\n * app's type-check fails with TS6142.\n *\n * Only alias targets that are non-relative and point at an existing\n * `extension-manifest.ts` (the shape the SDK's `extend` generator writes) are\n * touched; other aliases that would still trip TS5090 are reported with a\n * warning. A file is only written when something in it changes, and is then\n * re-serialised like every other JSON edit the SDK makes, so comments and\n * trailing commas in that file are lost. A file this migration cannot read is\n * skipped with a warning and never aborts the migration.\n */\n\nconst EXTENSION_MANIFEST_FILE = \"extension-manifest.ts\";\nconst IRIS_APP_MANIFEST_FILE = \"iris-app-manifest.ts\";\nconst APP_TSCONFIG_FILE = \"tsconfig.app.json\";\nconst JSX_VALUE = \"react-jsx\";\n\ntype JsonObject = Record<string, unknown>;\n\n// TODO(SDK-742): promote `isRecord` and `errorMessage` to @trackunit/shared-utils; they are copied here for now.\nconst isRecord = (value: unknown): value is JsonObject =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst errorMessage = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n/** Reads a tsconfig (devkit's `readJson` accepts comments and trailing commas); `undefined` when it is not a JSON object. */\nconst readJsonObject = (tree: Tree, filePath: string): JsonObject | undefined => {\n const parsed: unknown = readJson(tree, filePath);\n return isRecord(parsed) ? parsed : undefined;\n};\n\n/** TypeScript's own syntax diagnostics (TS1xxx), such as \"'}' expected\": the JSON of a file in the chain is broken. */\nconst isSyntaxDiagnostic = (diagnostic: { readonly code: number }): boolean => diagnostic.code < 2000;\n\n/**\n * What TypeScript itself makes of a tsconfig, `extends` chain included: the options and whether the chain could be\n * read in full. The Tree-backed host resolves the chain exactly like `tsc`, package-form bases such as\n * `@tsconfig/strictest` included. A chain with a missing base or broken JSON is not read in full, since an option\n * missing from what could be read may be set in what could not.\n */\nconst resolveEffectiveConfig = (tree: Tree, filePath: string) => {\n const parsed = readTsConfig(filePath, createTreeParseConfigHost(tree));\n return {\n options: parsed.options,\n chainReadable: !extendsResolutionFailed(parsed.errors) && !parsed.errors.some(isSyntaxDiagnostic),\n };\n};\n\n/**\n * The forward-slash form of an alias target the SDK wrote, or `undefined` when\n * the target is not one. The `extend` generator builds targets with\n * `path.join`, so ones created on Windows carry backslashes.\n */\nconst sdkExtensionManifestTarget = (tree: Tree, target: unknown): string | undefined => {\n if (typeof target !== \"string\") {\n return undefined;\n }\n const normalised = normalizePath(target);\n const isManifest = normalised === EXTENSION_MANIFEST_FILE || normalised.endsWith(`/${EXTENSION_MANIFEST_FILE}`);\n return isManifest && !isExternalModuleNameRelative(normalised) && tree.exists(normalised) ? normalised : undefined;\n};\n\n/** Whether any target of `paths` is an SDK extension manifest target that still lacks its `./`. */\nconst hasSdkAliasToRepair = (tree: Tree, paths: JsonObject): boolean =>\n Object.values(paths).some(\n targets => Array.isArray(targets) && targets.some(target => sdkExtensionManifestTarget(tree, target) !== undefined)\n );\n\n/**\n * Prefixes `./` onto every SDK extension manifest target of `paths`, in place.\n * The prefix never changes what an alias resolves to: with `baseUrl` set,\n * targets resolve against it and `./libs/x` is the same path as `libs/x`;\n * without it they resolve against the tsconfig and TypeScript 6 requires the\n * `./`.\n */\nconst prefixSdkAliases = (tree: Tree, paths: JsonObject): void => {\n for (const targets of Object.values(paths)) {\n if (!Array.isArray(targets)) {\n continue;\n }\n targets.forEach((target: unknown, index) => {\n const manifestPath = sdkExtensionManifestTarget(tree, target);\n if (manifestPath !== undefined) {\n targets[index] = `./${manifestPath}`;\n }\n });\n }\n};\n\n/**\n * Aliases this migration leaves alone that still break a type-checked build:\n * TS5090 applies to every non-relative `paths` target once no `baseUrl`\n * applies, not only the SDK's. They are reported, never rewritten.\n */\nconst remainingNonRelativeAliases = (tree: Tree, paths: JsonObject): ReadonlyArray<string> =>\n Object.entries(paths)\n .filter(\n ([, targets]) =>\n Array.isArray(targets) &&\n targets.some(\n (target: unknown) =>\n typeof target === \"string\" &&\n !isExternalModuleNameRelative(normalizePath(target)) &&\n sdkExtensionManifestTarget(tree, target) === undefined\n )\n )\n .map(([alias]) => alias);\n\nconst repairPathAliasesIn = (tree: Tree, rootTsConfigPath: string): void => {\n const tsConfig = readJsonObject(tree, rootTsConfigPath);\n if (tsConfig === undefined || !isRecord(tsConfig.compilerOptions) || !isRecord(tsConfig.compilerOptions.paths)) {\n return;\n }\n const { paths } = tsConfig.compilerOptions;\n\n // The warning is only true when no baseUrl applies, whether the file sets it or inherits it through `extends`.\n // A chain that cannot be read leaves that unknown, and an unknown is not worth a possibly false warning.\n const { options, chainReadable } = resolveEffectiveConfig(tree, rootTsConfigPath);\n const remaining = chainReadable && options.baseUrl === undefined ? remainingNonRelativeAliases(tree, paths) : [];\n if (remaining.length > 0) {\n logger.warn(\n `${rootTsConfigPath} has path aliases with non-relative targets, which TypeScript rejects when no baseUrl is set (TS5090): ${remaining.join(\", \")}. They were not written by the Iris App SDK, so they were left as they are; add a leading \"./\" to their targets if the workspace sets no baseUrl.`\n );\n }\n\n if (hasSdkAliasToRepair(tree, paths)) {\n updateJson<JsonObject>(tree, rootTsConfigPath, json => {\n if (isRecord(json.compilerOptions) && isRecord(json.compilerOptions.paths)) {\n prefixSdkAliases(tree, json.compilerOptions.paths);\n }\n return json;\n });\n logger.info(`Repaired SDK path aliases in ${rootTsConfigPath}: prefixed \"./\" onto extension manifest paths.`);\n }\n};\n\n/**\n * Prefixes `./` onto the `paths` entries of the root tsconfig that point at an\n * existing project's `extension-manifest.ts`.\n *\n * @param tree - Nx virtual file tree.\n */\nexport const repairSdkPathAliases = (tree: Tree): void => {\n // Typed `string | null`, but at runtime it falls back to `tsconfig.base.json` even when neither candidate exists,\n // so a path that is not there has to be checked for as well.\n const rootTsConfigPath = getRootTsConfigPathInTree(tree);\n if (rootTsConfigPath === null || !tree.exists(rootTsConfigPath)) {\n return;\n }\n\n try {\n repairPathAliasesIn(tree, rootTsConfigPath);\n } catch (error) {\n logger.warn(`Skipped path alias repair for ${rootTsConfigPath}: ${errorMessage(error)}`);\n }\n};\n\nconst irisAppRoots = (tree: Tree): ReadonlyArray<string> =>\n Array.from(getProjects(tree).values(), project => project.root).filter(root =>\n tree.exists(joinPathFragments(root, IRIS_APP_MANIFEST_FILE))\n );\n\nconst addJsxToApp = (tree: Tree, appRoot: string): void => {\n const appTsConfigPath = joinPathFragments(appRoot, APP_TSCONFIG_FILE);\n\n if (!tree.isFile(appTsConfigPath)) {\n logger.warn(`Skipped jsx repair for ${appRoot}: ${appTsConfigPath} not found.`);\n return;\n }\n\n const appTsConfig = readJsonObject(tree, appTsConfigPath);\n if (appTsConfig === undefined) {\n logger.warn(`Skipped jsx repair for ${appTsConfigPath}: it is not a JSON object.`);\n return;\n }\n if (appTsConfig.compilerOptions !== undefined && !isRecord(appTsConfig.compilerOptions)) {\n logger.warn(`Skipped jsx repair for ${appTsConfigPath}: its compilerOptions is not an object.`);\n return;\n }\n\n // Only a chain read in full can show `jsx` is missing, so an unreadable one is left alone.\n const { options, chainReadable } = resolveEffectiveConfig(tree, appTsConfigPath);\n if (!chainReadable || options.jsx !== undefined) {\n return;\n }\n\n updateJson<JsonObject>(tree, appTsConfigPath, json => ({\n ...json,\n compilerOptions: { ...(isRecord(json.compilerOptions) ? json.compilerOptions : {}), jsx: JSX_VALUE },\n }));\n logger.info(`Added \"jsx\": \"${JSX_VALUE}\" to ${appTsConfigPath}.`);\n};\n\n/**\n * Adds `jsx: \"react-jsx\"` to the `tsconfig.app.json` of every Iris app (a\n * project with an `iris-app-manifest.ts`) whose effective tsconfig chain\n * (`tsconfig.app.json` -> `tsconfig.json` -> `tsconfig.base.json`, via\n * `extends`) sets no `jsx`. An app that configures `jsx` anywhere in the chain,\n * or whose chain cannot be read in full, is left alone.\n *\n * @param tree - Nx virtual file tree.\n */\nexport const addJsxToIrisApps = (tree: Tree): void => {\n for (const appRoot of irisAppRoots(tree)) {\n try {\n addJsxToApp(tree, appRoot);\n } catch (error) {\n logger.warn(`Skipped jsx repair for ${appRoot}: ${errorMessage(error)}`);\n }\n }\n};\n\n/**\n * Repairs tsconfig defects the SDK left in existing workspaces.\n *\n * @param tree - Nx virtual file tree.\n */\nexport const repairTsconfig = (tree: Tree): void => {\n repairSdkPathAliases(tree);\n addJsxToIrisApps(tree);\n};\n\nexport default repairTsconfig;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classname-ast-rewrite.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app/migrations/utils/classname-ast-rewrite.ts"],"names":[],"mappings":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AAO;QAEzD,MAAM,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC7C,MAAM,SAAS,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,qBAAqB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;QACjG,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAE/B,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QACjD,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAClC,IAAU,EACV,UAAkB,EAClB,OAAoD;IAEpD,IAAA,6BAAoB,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE;QAChD,IAAI,CAAC,IAAA,wBAAgB,EAAC,QAAQ,CAAC;YAAE,OAAO;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7C,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO;QAC7B,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { visitNotIgnoredFiles, type Tree } from \"@nx/devkit\";\nimport {\n findClassnameStringsInAttribute,\n findClassnameStringsInCall,\n findClassnameStringsInVariable,\n quoteString,\n type ClassnameLocation,\n} from \"@trackunit/css-classname-utils\";\nimport { AST_NODE_TYPES, type TSESTree } from \"@typescript-eslint/types\";\nimport { parse, simpleTraverse } from \"@typescript-eslint/typescript-estree\";\n\n/**\n * Shared TSESTree parsing/traversal/splice helpers for classname-rewriting Nx\n * migrations (the `p-content-space-codemod` and any future codemod that needs\n * to detect and rewrite Tailwind classnames across a Tree).\n *\n * `@trackunit/css-classname-utils`'s detection helpers\n * (`findClassnameStringsInAttribute`/`InCall`/`InVariable`) expect TSESTree AST\n * nodes, which today only ESLint's parser produces in this repo. Nx migrations\n * run outside of ESLint, so this module wraps\n * `@typescript-eslint/typescript-estree`'s `parse` (the same underlying parser\n * `@typescript-eslint/parser` delegates to) to turn a raw source string into an\n * equivalent TSESTree `Program`, then re-splices edits directly against the\n * original source string by AST node range (mirroring the range-splice\n * approach `insertAttributeIntoOpeningTag` in\n * `libs/react/components/migrations/utils/jsx-utils.ts` uses for the\n * TypeScript-compiler-API case).\n */\n\n/**\n * Parses raw TypeScript/TSX source into a TSESTree `Program` AST.\n *\n * `jsx: true` is always passed (harmless for plain `.ts` files) so callers\n * don't need to branch on file extension before parsing.\n */\nexport function parseTsestreeSource(content: string): TSESTree.Program {\n return parse(content, { jsx: true, loc: true, range: true });\n}\n\n/**\n * Finds every classname string location in a parsed source: JSX\n * `className`/`class` attributes, Tailwind-function calls (`cva`, `cn`,\n * `clsx`, etc. — see `TAILWIND_FUNCTIONS`), and\n * `*Class`/`*ClassName`/`*Classes`-suffixed variable declarators.\n *\n * Walks the AST with `simpleTraverse` (shipped by\n * `@typescript-eslint/typescript-estree`) instead of a hand-rolled\n * visitor-keys walker, since it already knows every node type's visitor keys\n * for the resolved parser version.\n */\nexport function findClassnameLocations(program: TSESTree.Program): Array<ClassnameLocation> {\n const locations: Array<ClassnameLocation> = [];\n\n simpleTraverse(program, {\n enter: node => {\n if (node.type === AST_NODE_TYPES.JSXAttribute) {\n locations.push(...findClassnameStringsInAttribute(node));\n } else if (node.type === AST_NODE_TYPES.CallExpression) {\n locations.push(...findClassnameStringsInCall(node));\n } else if (node.type === AST_NODE_TYPES.VariableDeclarator) {\n locations.push(...findClassnameStringsInVariable(node));\n }\n },\n });\n\n return locations;\n}\n\n/** A single range-based text splice against the original source string. */\nexport type ClassnameEdit = {\n range: TSESTree.Range;\n text: string;\n};\n\n/**\n * Builds the edit(s) needed to apply `transform` to a `ClassnameLocation`'s\n * `fixNode`, splicing by the node's own `.range` against the original source\n * (there is no ESLint `SourceCode`/fixer available outside of rule\n * execution).\n *\n * - `Literal`: one edit replacing the whole quoted literal, preserving the\n * original quote style via `quoteString`.\n * - `TemplateLiteral`: one edit per quasi whose raw text changes, splicing\n * only the text between the surrounding backtick/`${`/`}` delimiters so the\n * template's interpolated expressions are left untouched.\n *\n * Returns an empty array when `transform` doesn't change the value, so\n * callers can cheaply detect \"no-op\" locations.\n *\n * Prefer {@link buildEditsForLocation} when the caller has a full\n * `ClassnameLocation` — that path can drop an emptied JSX `className`\n * attribute entirely instead of leaving `className=\"\"`.\n */\nexport function buildClassnameEdits(\n fixNode: ClassnameLocation[\"fixNode\"],\n transform: (value: string) => string\n): Array<ClassnameEdit> {\n if (fixNode.type === AST_NODE_TYPES.Literal) {\n if (typeof fixNode.value !== \"string\") return [];\n const newValue = transform(fixNode.value);\n if (newValue === fixNode.value) return [];\n return [{ range: fixNode.range, text: quoteString(newValue, fixNode) }];\n }\n\n const edits: Array<ClassnameEdit> = [];\n for (const quasi of fixNode.quasis) {\n const newRaw = transform(quasi.value.raw);\n if (newRaw === quasi.value.raw) continue;\n const start = quasi.range[0] + 1;\n const end = quasi.range[1] - (quasi.tail ? 1 : 2);\n edits.push({ range: [start, end], text: newRaw });\n }\n return edits;\n}\n\n/**\n * Like {@link buildClassnameEdits}, but when a JSX `className`/`class`\n * attribute's token list becomes empty, removes the whole attribute\n * (including a single run of preceding horizontal whitespace) instead of\n * writing `className=\"\"`.\n *\n * Non-JSX locations (cva/cn/clsx calls, `*ClassName` variables) still fall\n * through to an empty-string literal — deleting those would require\n * statement-level surgery we deliberately do not attempt here.\n */\nexport function buildEditsForLocation(\n location: ClassnameLocation,\n transform: (value: string) => string,\n sourceContent: string\n): Array<ClassnameEdit> {\n const { fixNode, context, reportNode } = location;\n\n if (\n context.type === \"jsx-attribute\" &&\n reportNode.type === AST_NODE_TYPES.JSXAttribute &&\n fixNode.type === AST_NODE_TYPES.Literal &&\n typeof fixNode.value === \"string\"\n ) {\n const newValue = transform(fixNode.value);\n if (newValue === fixNode.value) return [];\n if (newValue === \"\") {\n return [buildJsxAttributeRemovalEdit(reportNode, sourceContent)];\n }\n return [{ range: fixNode.range, text: quoteString(newValue, fixNode) }];\n }\n\n return buildClassnameEdits(fixNode, transform);\n}\n\n/**\n * Removes a JSX attribute, swallowing the horizontal whitespace immediately\n * before it so `<div className=\"x\">` becomes `<div>` rather than `<div >`.\n */\nfunction buildJsxAttributeRemovalEdit(attribute: TSESTree.JSXAttribute, sourceContent: string): ClassnameEdit {\n let start = attribute.range[0];\n while (start > 0 && /[ \\t]/.test(sourceContent[start - 1] ?? \"\")) {\n start -= 1;\n }\n return { range: [start, attribute.range[1]], text: \"\" };\n}\n\n/**\n * Applies a batch of range-based edits to `content`, splicing in\n * reverse-offset order so that an earlier edit's range is never invalidated\n * by one applied after it.\n */\nexport function applyEdits(content: string, edits: ReadonlyArray<ClassnameEdit>): string {\n const byDescendingStart = [...edits].sort((a, b) => b.range[0] - a.range[0]);\n\n let result = content;\n for (const edit of byDescendingStart) {\n const [start, end] = edit.range;\n result = result.slice(0, start) + edit.text + result.slice(end);\n }\n return result;\n}\n\nconst REWRITABLE_EXTENSIONS: Array<string> = [\".ts\", \".tsx\"];\n\n/**\n * Manifest files must never be mutated by a classname-rewriting migration\n * (a hard Success Criterion of GLU-1570). No in-repo extension currently\n * declares a `sourceRoot` that overlaps its own manifest file, but this\n * filename guard is defense-in-depth so that invariant doesn't depend\n * entirely on that data convention holding forever.\n */\nconst MANIFEST_FILENAME_PATTERN = /(^|\\/)(iris-app-manifest|extension-manifest)\\.ts$/;\n\n/**\n * `true` for `.ts`/`.tsx` files a classname-rewriting migration is allowed\n * to read/write — excludes `iris-app-manifest.ts`/`extension-manifest.ts`\n * files. Shared by every transform/report module in this codemod so the\n * file-extension allowlist and manifest exclusion live in exactly one place.\n */\nexport const isRewritableFile = (filePath: string): boolean =>\n REWRITABLE_EXTENSIONS.some(ext => filePath.endsWith(ext)) && !MANIFEST_FILENAME_PATTERN.test(filePath);\n\n/**\n * Walks every rewritable file under `sourceRoot`, and for files passing the\n * cheap `shouldConsider` substring pre-check, parses them, finds every\n * classname location, applies `transform` to each, and writes back any file\n * that actually changed.\n *\n * Shared by `rewritePageContent` and `removeRedundantPadding` so the\n * walk → pre-filter → parse → find → edit → write skeleton lives in exactly\n * one place instead of being duplicated per transform.\n */\nexport function transformClassnamesUnderSourceRoot(\n tree: Tree,\n sourceRoot: string,\n shouldConsider: (content: string) => boolean,\n transform: (value: string) => string\n): { filesChanged: Array<string> } {\n const filesChanged: Array<string> = [];\n\n visitNotIgnoredFiles(tree, sourceRoot, filePath => {\n if (!isRewritableFile(filePath)) return;\n\n const content = tree.read(filePath, \"utf-8\");\n if (content === null || !shouldConsider(content)) return;\n\n const program = parseTsestreeSource(content);\n const locations = findClassnameLocations(program);\n const edits = locations.flatMap(location => buildEditsForLocation(location, transform, content));\n if (edits.length === 0) return;\n\n tree.write(filePath, applyEdits(content, edits));\n filesChanged.push(filePath);\n });\n\n return { filesChanged };\n}\n\n/**\n * Read-only walk of every rewritable file under `sourceRoot`, invoking\n * `visitor` with each file's path and content. Never writes. Shared by\n * `findUnresolvedSurface`'s detection pass, which only needs to inspect\n * content, not rewrite it.\n */\nexport function visitRewritableFiles(\n tree: Tree,\n sourceRoot: string,\n visitor: (filePath: string, content: string) => void\n): void {\n visitNotIgnoredFiles(tree, sourceRoot, filePath => {\n if (!isRewritableFile(filePath)) return;\n const content = tree.read(filePath, \"utf-8\");\n if (content === null) return;\n visitor(filePath, content);\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-extension-types.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app/migrations/utils/resolve-extension-types.ts"],"names":[],"m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AC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,eAAM,CAAC,IAAI,CAAC,iEAAiE,OAAO,EAAE,CAAC,CAAC;QACxF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC;IAClD,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,MAAM,KAAK,SAAS;YAAE,SAAS;QACnC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,OAAe;IACxC,OAAO,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,yBAAyB,CAAC,SAAiB;IAClD,OAAO,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { logger, visitNotIgnoredFiles, type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\n\nexport type ResolvedExtension = {\n /** The extension manifest's `id` field. */\n id: string;\n /** SCREAMING_SNAKE extension type discriminator, e.g. \"ADMIN_EXTENSION\". */\n type: string;\n /** Repo-relative source root for the extension, e.g. \"libs/administration/api-keys/src\". */\n sourceRoot: string;\n /** Repo-relative path to the resolved `extension-manifest.ts` file. */\n extensionManifestPath: string;\n /**\n * The extension manifest's entry component file, e.g. \"index.tsx\".\n * Optional so hand-written fixtures/tests don't need to set it; when\n * produced by `resolveExtensionTypes` it is always populated, defaulting\n * to `\"index.tsx\"` per `AbstractExtensionManifest.main`'s own documented\n * default when the manifest doesn't set it explicitly.\n */\n main?: string;\n /** App names (`apps/<name>`) that import this extension. Lets callers verify dedup. */\n ownerApps: Array<string>;\n};\n\nexport type UnresolvedExtensionImport = {\n /** The app (`apps/<name>`) that references the unresolvable specifier. */\n app: string;\n /** The module specifier that could not be resolved via `tsconfig.base.json` paths. */\n specifier: string;\n};\n\nexport type ResolveExtensionTypesResult = {\n resolved: Array<ResolvedExtension>;\n /**\n * Extensions referenced by an app's `extensions` array whose import\n * specifier could not be resolved to a file via `tsconfig.base.json`'s\n * `compilerOptions.paths`. Surfaced here instead of thrown, so a single\n * unresolvable/renamed package doesn't abort the whole migration.\n */\n unresolved: Array<UnresolvedExtensionImport>;\n};\n\nconst APPS_MANIFEST_PATTERN = /^apps\\/([^/]+)\\/iris-app-manifest\\.ts$/;\nconst DEFAULT_ENTRY_COMPONENT_FILE = \"index.tsx\";\n\n/**\n * Statically resolves every `apps/*\\/iris-app-manifest.ts`'s declared\n * `extensions` to a concrete `type` + `sourceRoot`, deduping extensions\n * shared by multiple apps into a single entry.\n *\n * Uses the TypeScript compiler API against the Nx `Tree` (not `fs`/dynamic\n * `import()`), so uncommitted edits held only in the Tree are seen and the\n * migration stays deterministic.\n */\nexport function resolveExtensionTypes(tree: Tree): ResolveExtensionTypesResult {\n const tsconfigPaths = readTsconfigPaths(tree);\n const resolvedByPath = new Map<string, ResolvedExtension>();\n const unresolved: Array<UnresolvedExtensionImport> = [];\n\n visitNotIgnoredFiles(tree, \"apps\", filePath => {\n const match = APPS_MANIFEST_PATTERN.exec(filePath);\n if (match === null) return;\n const appName = match[1];\n if (appName === undefined) return;\n\n const content = tree.read(filePath, \"utf-8\");\n if (content === null) return;\n\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);\n const manifestObject = resolveDefaultExportObjectLiteral(sourceFile);\n if (manifestObject === null) return;\n\n const extensionIdentifiers = getExtensionIdentifiers(manifestObject, filePath);\n if (extensionIdentifiers.length === 0) return;\n\n const importSpecifiersByLocalName = getImportSpecifiersByLocalName(sourceFile);\n\n for (const identifierName of extensionIdentifiers) {\n const specifier = importSpecifiersByLocalName.get(identifierName);\n if (specifier === undefined) {\n logger.warn(\n `[resolve-extension-types] Could not find an import for \"${identifierName}\" referenced in ${filePath}'s extensions array.`\n );\n continue;\n }\n\n const extensionManifestPath = tsconfigPaths.get(specifier);\n if (extensionManifestPath === undefined) {\n logger.warn(\n `[resolve-extension-types] Could not resolve module specifier \"${specifier}\" (from ${filePath}) via tsconfig.base.json paths.`\n );\n unresolved.push({ app: appName, specifier });\n continue;\n }\n\n const existing = resolvedByPath.get(extensionManifestPath);\n if (existing !== undefined) {\n if (!existing.ownerApps.includes(appName)) existing.ownerApps.push(appName);\n continue;\n }\n\n const resolvedExtension = resolveExtensionManifest(tree, extensionManifestPath);\n if (resolvedExtension === null) {\n logger.warn(\n `[resolve-extension-types] Could not resolve extension manifest fields from \"${extensionManifestPath}\" (imported as \"${specifier}\" in ${filePath}).`\n );\n continue;\n }\n\n resolvedByPath.set(extensionManifestPath, { ...resolvedExtension, ownerApps: [appName] });\n }\n });\n\n return { resolved: [...resolvedByPath.values()], unresolved };\n}\n\nfunction resolveExtensionManifest(\n tree: Tree,\n extensionManifestPath: string\n): Omit<ResolvedExtension, \"ownerApps\"> | null {\n const content = tree.read(extensionManifestPath, \"utf-8\");\n if (content === null) return null;\n\n const sourceFile = ts.createSourceFile(\n extensionManifestPath,\n content,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS\n );\n const extensionObject = resolveDefaultExportObjectLiteral(sourceFile);\n if (extensionObject === null) return null;\n\n const id = getStringLiteralProperty(extensionObject, \"id\");\n const type = getStringLiteralProperty(extensionObject, \"type\");\n const sourceRoot = getStringLiteralProperty(extensionObject, \"sourceRoot\");\n if (id === null || type === null || sourceRoot === null) return null;\n\n const main = getStringLiteralProperty(extensionObject, \"main\") ?? DEFAULT_ENTRY_COMPONENT_FILE;\n\n return { id, type, sourceRoot, extensionManifestPath, main };\n}\n\n/**\n * Finds the object literal behind `export default <expr>;`, following a\n * single level of identifier indirection (e.g. `const x = {...}; export\n * default x;`) since that's the shape every real manifest in this repo uses.\n */\nfunction resolveDefaultExportObjectLiteral(sourceFile: ts.SourceFile): ts.ObjectLiteralExpression | null {\n for (const statement of sourceFile.statements) {\n if (!ts.isExportAssignment(statement) || statement.isExportEquals) continue;\n const expr = statement.expression;\n if (ts.isObjectLiteralExpression(expr)) return expr;\n if (ts.isIdentifier(expr)) return findObjectLiteralVariable(sourceFile, expr.text);\n }\n return null;\n}\n\nfunction findObjectLiteralVariable(sourceFile: ts.SourceFile, name: string): ts.ObjectLiteralExpression | null {\n for (const statement of sourceFile.statements) {\n if (!ts.isVariableStatement(statement)) continue;\n for (const declaration of statement.declarationList.declarations) {\n if (!ts.isIdentifier(declaration.name) || declaration.name.text !== name) continue;\n if (declaration.initializer !== undefined && ts.isObjectLiteralExpression(declaration.initializer)) {\n return declaration.initializer;\n }\n }\n }\n return null;\n}\n\nfunction getExtensionIdentifiers(manifestObject: ts.ObjectLiteralExpression, filePath: string): Array<string> {\n for (const property of manifestObject.properties) {\n if (!ts.isPropertyAssignment(property)) continue;\n if (!ts.isIdentifier(property.name) || property.name.text !== \"extensions\") continue;\n if (!ts.isArrayLiteralExpression(property.initializer)) return [];\n\n const identifiers: Array<string> = [];\n for (const element of property.initializer.elements) {\n if (ts.isIdentifier(element)) {\n identifiers.push(element.text);\n } else {\n logger.warn(\n `[resolve-extension-types] Skipping a non-identifier element of the \"extensions\" array in ${filePath} (only \\`import x from \"...\"\\`-style identifiers can be statically resolved).`\n );\n }\n }\n return identifiers;\n }\n return [];\n}\n\nfunction getImportSpecifiersByLocalName(sourceFile: ts.SourceFile): Map<string, string> {\n const result = new Map<string, string>();\n for (const statement of sourceFile.statements) {\n if (!ts.isImportDeclaration(statement)) continue;\n const moduleSpecifier = statement.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier)) continue;\n const specifier = moduleSpecifier.text;\n\n const importClause = statement.importClause;\n if (importClause === undefined) continue;\n\n if (importClause.name !== undefined) {\n result.set(importClause.name.text, specifier);\n }\n\n const namedBindings = importClause.namedBindings;\n if (namedBindings !== undefined && ts.isNamedImports(namedBindings)) {\n for (const element of namedBindings.elements) {\n result.set(element.name.text, specifier);\n }\n }\n }\n return result;\n}\n\nfunction getStringLiteralProperty(objectLiteral: ts.ObjectLiteralExpression, propertyName: string): string | null {\n for (const property of objectLiteral.properties) {\n if (!ts.isPropertyAssignment(property)) continue;\n if (!ts.isIdentifier(property.name) || property.name.text !== propertyName) continue;\n return ts.isStringLiteral(property.initializer) ? property.initializer.text : null;\n }\n return null;\n}\n\ntype TsconfigPaths = { compilerOptions?: { paths?: Record<string, Array<string>> } };\n\nfunction readTsconfigPaths(tree: Tree): Map<string, string> {\n const result = new Map<string, string>();\n const content = tree.read(\"tsconfig.base.json\", \"utf-8\");\n if (content === null) {\n logger.warn(\"[resolve-extension-types] tsconfig.base.json not found; no extension imports will resolve.\");\n return result;\n }\n\n let parsed: TsconfigPaths;\n try {\n parsed = JSON.parse(stripJsonComments(content));\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.warn(`[resolve-extension-types] Failed to parse tsconfig.base.json: ${message}`);\n return result;\n }\n\n const paths = parsed.compilerOptions?.paths ?? {};\n for (const [specifier, targets] of Object.entries(paths)) {\n const target = targets[0];\n if (target === undefined) continue;\n result.set(specifier, normalizeRepoRelativePath(target));\n }\n return result;\n}\n\n/**\n * `tsconfig.base.json` is committed without comments today, but strip\n * line comments and block comments defensively in case that changes, so a\n * stray comment doesn't hard-fail `JSON.parse`. The line-comment regex\n * requires the preceding character not be `:` so it doesn't mangle URL-like\n * string values (e.g. `\"https://...\"`).\n */\nfunction stripJsonComments(content: string): string {\n return content.replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\").replace(/(^|[^:])\\/\\/.*$/gm, \"$1\");\n}\n\nfunction normalizeRepoRelativePath(pathValue: string): string {\n return pathValue.replace(/^\\.\\//, \"\");\n}\n"]}
|
package/migrations.json
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
"version": "2.5.13",
|
|
5
5
|
"description": "Rewrite the legacy page-content Tailwind class to overflow-auto p-content-space, invent p-content-space on high-confidence Asset Home/Site Home/Admin content shells, and remove now-redundant bottom-inset classes.",
|
|
6
6
|
"implementation": "./migrations/p-content-space-codemod/orchestrator"
|
|
7
|
+
},
|
|
8
|
+
"v2-16-6-repair-tsconfig": {
|
|
9
|
+
"version": "2.16.6",
|
|
10
|
+
"description": "Repair the tsconfig of SDK-created workspaces so a type-checked build passes: prefix ./ on SDK-created extension path aliases in tsconfig.base.json (fixes TS5090) and add jsx react-jsx to Iris apps whose tsconfig chain sets none (fixes TS6142). Developer-written aliases and existing jsx/baseUrl settings are left untouched.",
|
|
11
|
+
"implementation": "./migrations/repair-tsconfig/repair-tsconfig"
|
|
7
12
|
}
|
|
8
13
|
}
|
|
9
14
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.16",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"generators": "./generators.json",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"node": ">=24.x"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@trackunit/css-classname-utils": "0.0.
|
|
13
|
+
"@trackunit/css-classname-utils": "0.0.124",
|
|
14
14
|
"@typescript-eslint/types": "8.71.2",
|
|
15
15
|
"@typescript-eslint/typescript-estree": "8.71.2",
|
|
16
16
|
"pacote": "^21.5.1",
|
|
@@ -26,16 +26,30 @@
|
|
|
26
26
|
"@nx/react": "23.3.0",
|
|
27
27
|
"@npmcli/arborist": "^9.1.9",
|
|
28
28
|
"win-ca": "^3.5.1",
|
|
29
|
-
"
|
|
30
|
-
"@trackunit/
|
|
31
|
-
"@trackunit/
|
|
32
|
-
"@trackunit/
|
|
29
|
+
"node-forge": "^1.4.3",
|
|
30
|
+
"@trackunit/iris-app-build-utilities": "3.0.28",
|
|
31
|
+
"@trackunit/react-graphql-tools": "1.23.47",
|
|
32
|
+
"@trackunit/shared-utils": "1.22.43",
|
|
33
|
+
"@trackunit/iris-app-api": "2.13.16",
|
|
33
34
|
"tslib": "^2.6.2",
|
|
34
35
|
"@clack/prompts": "^1.8.1",
|
|
35
36
|
"@nx/devkit": "23.3.0",
|
|
36
37
|
"nx": "23.3.0"
|
|
37
38
|
},
|
|
38
39
|
"migrations": "./migrations.json",
|
|
40
|
+
"pinnedVersions": {
|
|
41
|
+
"@trackunit/iris-app-api": "2.13.16",
|
|
42
|
+
"@trackunit/react-components": "6.0.38",
|
|
43
|
+
"@trackunit/react-core-contexts": "2.20.39",
|
|
44
|
+
"@trackunit/css-core": "1.22.44",
|
|
45
|
+
"@trackunit/iris-app-sdk-vite": "1.11.50",
|
|
46
|
+
"@trackunit/react-core-contexts-test": "1.28.34",
|
|
47
|
+
"@trackunit/react-vite-test-setup": "0.0.216",
|
|
48
|
+
"@trackunit/iris-app-runtime-core": "1.28.34",
|
|
49
|
+
"@trackunit/serverside-utils": "0.5.302",
|
|
50
|
+
"@trackunit/migrations": "0.2.159",
|
|
51
|
+
"@trackunit/eslint-plugin-trackunit": "0.8.6"
|
|
52
|
+
},
|
|
39
53
|
"types": "./src/index.d.ts",
|
|
40
54
|
"type": "commonjs"
|
|
41
55
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/submit/executor.ts"],"names":[],"mappings":";;AAyIA,8BAqCC;;AA5KD,+CAA4C;AAC5C,kFAA0E;AAC1E,8DAAwC;AACxC,uDAAiC;AACjC,g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CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YACjE,MAAM,SAAS,GAAG,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,CAAE,KAA+B,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YAC/F,MAAM,IAAI,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;YACnE,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;YACxE,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,IAAI,aAAa,CAAC,EAAE,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,sBAAsB,QAAQ,CAAC,OAAO,OAAO,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;YAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,YAAY,CACpB,GAAG,aAAa,CAAC,UAAU,KAAK,MAAM,aAAa,CAAC,IAAI,EAAE,eAAe,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,EAChH,aAAa,CAAC,MAAM,CACrB,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport { PackageJson } from \"@npm/types\";\nimport { Arborist } from \"@npmcli/arborist\";\nimport { checkPackageVersion } from \"@trackunit/iris-app-build-utilities\";\nimport * as libpub from \"libnpmpublish\";\nimport * as pacote from \"pacote\";\nimport readline from \"readline\";\nimport { inject } from \"win-ca\";\nimport { getAccessToken } from \"../utils/authentication\";\nimport { getSettings, Settings } from \"../utils/irisAppServerSettings\";\nimport { SubmitExecutorSchema } from \"./schema\";\n\n// Inject Windows trusted certificates to support Zscalar and other traffic inspection systems.\ninject(\"+\");\n\ntype SubmitError = Error & {\n statusCode?: number;\n code?: string;\n type?: string;\n headers?: { [key: string]: string };\n};\n\nclass NpmConflictError extends Error {}\n\nclass NpmGeneralError extends Error {\n public constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly code?: string,\n public readonly type?: string\n ) {\n super(message);\n }\n}\n\nclass ApproveError extends Error {\n public constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly code?: string\n ) {\n super(message);\n }\n}\n\nfunction sleep(time: number) {\n return new Promise(resolve => setTimeout(resolve, time));\n}\n\n// Errno-style codes that indicate the request never reached the registry at all\n// (DNS/connection/timeout failures at the transport layer), as opposed to local\n// validation errors (e.g. libnpmpublish's EPRIVATE/EBADSEMVER/EUSAGE) which carry\n// a code but are permanent and can never succeed on retry. Kept aligned with\n// make-fetch-happen's own RETRY_ERRORS list (used by the submit path) plus the\n// undici error codes doApproveApp's native fetch can raise.\n//\n// ENOTFOUND (DNS failure) is deliberately included even though make-fetch-happen\n// itself excludes it as \"bad hostname, or offline\" - a DNS blip during a VPN/\n// network transition is common enough in practice that failing fast here would\n// trade one wasted-wait problem for developers hitting spurious permanent\n// failures on flaky networks. This is a judgment call, not a clear-cut default.\nconst RETRYABLE_TRANSPORT_CODES = new Set([\n \"ENOTFOUND\",\n \"ECONNRESET\",\n \"ECONNREFUSED\",\n \"ETIMEDOUT\",\n \"EAI_AGAIN\",\n \"ERR_SOCKET_TIMEOUT\",\n \"EADDRINUSE\",\n // from @npmcli/agent, surfaced through make-fetch-happen\n \"ECONNECTIONTIMEOUT\",\n \"EIDLETIMEOUT\",\n \"ERESPONSETIMEOUT\",\n \"ETRANSFERTIMEOUT\",\n // doApproveApp uses Node's native fetch (undici), which raises its own\n // codes distinct from the classic Node errno codes above.\n \"UND_ERR_CONNECT_TIMEOUT\",\n \"UND_ERR_HEADERS_TIMEOUT\",\n \"UND_ERR_BODY_TIMEOUT\",\n \"UND_ERR_SOCKET\", // e.g. \"other side closed\" on a reused keep-alive connection\n]);\n\n/**\n * Decide whether a failed submit/approve attempt is worth retrying.\n *\n * This is an allowlist, not a denylist: only failures with a real chance of\n * succeeding on a later attempt are retried - 5xx responses, 408/429 (timeout/\n * rate-limited), a transport-level failure that never reached the registry at\n * all (identified by a known transient errno code), or a minipass-fetch request\n * timeout (which surfaces with the generic code FETCH_ERROR, distinguishable\n * only via its `type: \"request-timeout\"`). Everything else - permanent 4xx\n * errors, local validation errors with an unrelated code (e.g. EBADSEMVER), or\n * any other unrecognized error shape - is treated as non-retryable by default.\n *\n * @param {number} [statusCode] The HTTP status code of the failed attempt, if any.\n * @param {string} [code] The error's errno-style code, if any (no statusCode implies no HTTP response was received).\n * @param {string} [type] The error's `type` field, if any. Only consulted when `code === \"FETCH_ERROR\"`, since that's the one code minipass-fetch's FetchError uses generically for several failure kinds - `type` is what distinguishes a timeout from the others.\n * @returns {boolean} Whether the attempt should be retried.\n */\nfunction isRetryableError(statusCode?: number, code?: string, type?: string): boolean {\n if (statusCode !== undefined) {\n return statusCode >= 500 || statusCode === 408 || statusCode === 429;\n }\n if (code === undefined) {\n return false;\n }\n return RETRYABLE_TRANSPORT_CODES.has(code) || (code === \"FETCH_ERROR\" && type === \"request-timeout\");\n}\n\n/**\n * Older iris-app-sdk-server releases answer a failed outbound fetch of their own with\n * 400 `{ error: \"fetch failed\" }`, which npm-registry-fetch appends to the message as \" - fetch failed\".\n * That is a transient server-side failure, not a rejected package.\n *\n * @param {NpmGeneralError} error The failed upload attempt.\n * @returns {boolean} Whether the attempt should be retried.\n */\nfunction isRetryableUploadError(error: NpmGeneralError): boolean {\n if (error.statusCode === 400 && error.message.includes(\" - fetch failed.\")) {\n return true;\n }\n return isRetryableError(error.statusCode, error.code, error.type);\n}\n\nfunction isRetryableApproveError(statusCode?: number, code?: string, type?: string): boolean {\n // Same as isRetryableError but also accept 404 for approvals.\n // 404 can happen spuriously on approval\n return (statusCode !== undefined && statusCode === 404) || isRetryableError(statusCode, code, type);\n}\n\n/**\n * Submit the package to the npm registry.\n *\n * @param {SubmitExecutorSchema} options The options provided to the executor.\n * @returns {Promise<{ success: boolean }>} The result of the submit.\n * @throws {Error} When `@trackunit/*` dependencies are a major version behind or cannot be looked up; nothing is published.\n */\nexport default async function runExecutor(options: SubmitExecutorSchema) {\n await checkPackageVersion({ report: true, block: true });\n const settings = getSettings();\n const linkToTerms = \"https://trackunit.com/terms-conditions-marketplace/\";\n\n try {\n if (options.devTermsAndConditions?.toLowerCase() !== \"accept\" && !settings.devTermsAccept) {\n // Ask user if they accept dev terms and conditions.\n const userInput = await promptUserForInput(\n `Do you accept the developer terms and conditions? \\n(${linkToTerms}) \\n\\n 📝 Type 'accept' to proceed: `\n );\n if (userInput.toLowerCase() !== \"accept\") {\n throw new Error(`You must accept the developer terms and conditions (${linkToTerms}) to continue.`);\n }\n }\n const tokenData = await getAccessToken(settings.env);\n\n if (\"access_token\" in tokenData) {\n console.log(\"🥳 Successfully authenticated.\");\n\n const manifest = (await pacote.manifest(options.inputPath)) as PackageJson;\n const tarData = await pacote.tarball(options.inputPath, { Arborist });\n\n return await doUploadAppWithRetry(tokenData.access_token, manifest, tarData, settings, 10);\n } else if (\"error\" in tokenData) {\n if (tokenData.error === \"expired_token\") {\n throw new Error(\"⌛️ Authentication attempt expired\");\n } else {\n throw new Error(`Error occurred: ${tokenData.error} ${tokenData.error_description}`);\n }\n } else {\n throw new Error(\"Unknown error occurred\");\n }\n } catch (e) {\n console.error(\"❌ \", e);\n return { success: false };\n }\n}\n\nasync function doUploadAppWithRetry(\n accessToken: string,\n manifest: PackageJson,\n tarData: Buffer & pacote.FetchResult,\n settings: Settings,\n retryCount: number\n): Promise<{ success: boolean }> {\n try {\n return await doUploadApp(accessToken, manifest, tarData, settings);\n } catch (e) {\n if (e instanceof NpmConflictError) {\n console.error(\"❌ Unable to ship app package. Cannot submit over existing version.\");\n return { success: false };\n }\n\n if (!(e instanceof NpmGeneralError)) {\n // An error shape we don't recognize (e.g. a bug elsewhere in this function) -\n // log the full error/stack rather than a bare message so it stays debuggable.\n console.error(\"❌ Unable to ship app package. Got error from Iris App SDK repository.\", e);\n return { success: false };\n }\n\n if (!isRetryableUploadError(e)) {\n console.error(\"❌ Unable to ship app package.\", e.message);\n return { success: false };\n }\n\n if (retryCount > 1) {\n console.error(\n \"⚠️ Unable to ship app package. Got error from Iris App SDK repository. Retrying submit...\",\n e.message\n );\n await sleep(30000);\n return await doUploadAppWithRetry(accessToken, manifest, tarData, settings, retryCount - 1);\n } else {\n console.error(\"❌ Unable to ship app package. Got error from Iris App SDK repository.\", e.message);\n return { success: false };\n }\n }\n}\n\nasync function doUploadApp(\n accessToken: string,\n manifest: PackageJson,\n tarData: Buffer & pacote.FetchResult,\n settings: Settings\n): Promise<{ success: boolean }> {\n const npmFetchOptions: { registry?: string } & Record<string, string | boolean> = {};\n npmFetchOptions.registry = settings.repoUrl.toString();\n const repoHostAndPort = settings.repoUrl.hostname + (settings.repoUrl.port ? `:${settings.repoUrl.port}` : \"\");\n npmFetchOptions[`//${repoHostAndPort}${settings.repoUrl.pathname}:_authToken`] = accessToken;\n npmFetchOptions[`//${repoHostAndPort}${settings.repoUrl.pathname}/repo/:always-auth`] = true;\n\n console.log(\"🚢 Shipping the app package...\");\n const submitResult = await libpub.publish(manifest, tarData, npmFetchOptions).catch((err: SubmitError) => {\n if (err.statusCode === 409 || err.code === \"E409\" || err.code === \"EPUBLISHCONFLICT\") {\n return {\n ok: false,\n submitConflict: true,\n };\n } else {\n return {\n ok: false,\n statusCode: err.statusCode,\n code: err.code,\n type: err.type,\n headers: new Headers(err.headers),\n statusText: `Error`,\n text: () => Promise.resolve(`${err.name} ${err.message}`),\n };\n }\n });\n\n const warningsText = submitResult.headers?.get(\"TU-IRIS-APP-WARNINGS\");\n if (warningsText) {\n console.log(`⚠️ ${decodeURI(warningsText)}`);\n }\n\n if (submitResult.ok) {\n console.log(`🚀 Uploaded the app package version ${manifest.version}`);\n\n return await doApproveAppWithRetry(accessToken, manifest, settings, 3);\n } else if (\"submitConflict\" in submitResult) {\n if (process.env.SKIP_EXISTING === \"true\") {\n console.log(`⏩ Skipped submitting ${manifest.version} because the version is already submitted`);\n return await doApproveAppWithRetry(accessToken, manifest, settings, 3);\n } else {\n throw new NpmConflictError();\n }\n } else {\n throw new NpmGeneralError(\n `${submitResult.statusText} ${await submitResult.text()}. Trace ID: ${submitResult.headers.get(\"trace-id\")}`,\n \"statusCode\" in submitResult ? submitResult.statusCode : undefined,\n \"code\" in submitResult ? submitResult.code : undefined,\n \"type\" in submitResult ? submitResult.type : undefined\n );\n }\n}\n\nasync function promptUserForInput(query: string): Promise<string> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise(resolve => {\n rl.question(query, (input: string) => {\n rl.close();\n resolve(input);\n });\n });\n}\n\nasync function doApproveAppWithRetry(\n token: string,\n manifest: PackageJson,\n settings: Settings,\n retryCount: number\n): Promise<{ success: boolean }> {\n try {\n return await doApproveApp(token, manifest, settings);\n } catch (e) {\n if (!(e instanceof ApproveError)) {\n console.error(\"❌ Unable to approve app package. Got error from Iris App SDK repository.\", e);\n return { success: false };\n }\n\n if (!isRetryableApproveError(e.statusCode, e.code)) {\n console.error(\"❌ Unable to approve app package.\", e.message);\n return { success: false };\n }\n\n if (retryCount > 1) {\n console.error(\n \"⚠️ Unable to approve app package. Got approve error from Iris App SDK repository. Retrying approve...\",\n e.message\n );\n await sleep(30000);\n return await doApproveAppWithRetry(token, manifest, settings, retryCount - 1);\n } else {\n console.error(\"❌ Unable to approve app package. Got approve error from Iris App SDK repository.\", e.message);\n return { success: false };\n }\n }\n}\n\nasync function doApproveApp(token: string, manifest: PackageJson, settings: Settings) {\n if (process.env.TU_APPROVE === \"true\") {\n console.log(`🖋️ Approving the app...`);\n // A rejection here (e.g. DNS/connection/timeout failure) never produced an HTTP\n // response, so it's re-thrown as an ApproveError with no statusCode - carrying\n // the underlying cause's errno code (if any) so isRetryableError can recognize\n // genuine transport failures, and the cause's message so the log doesn't just\n // say \"fetch failed\" with no indication of what actually broke.\n const approveResult = await fetch(new URL(`${manifest.name}@${manifest.version}`, settings.approvalUrl), {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${token}`,\n },\n }).catch((err: Error) => {\n const cause = err.cause instanceof Error ? err.cause : undefined;\n const causeCode = cause && \"code\" in cause ? (cause as NodeJS.ErrnoException).code : undefined;\n const code = typeof causeCode === \"string\" ? causeCode : undefined;\n const reason = cause ? `${err.message}: ${cause.message}` : err.message;\n throw new ApproveError(reason, undefined, code);\n });\n\n if (approveResult.ok) {\n console.log(`✅ Approved version ${manifest.version} of ${manifest.name}.`);\n return { success: true };\n } else {\n throw new ApproveError(\n `${approveResult.statusText}, ${await approveResult.text()}, Trace ID: ${approveResult.headers.get(\"trace-id\")}`,\n approveResult.status\n );\n }\n } else {\n return { success: true };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/unpublish/executor.ts"],"names":[],"mappings":";;AAcA,8BAkDC;;AA9DD,uDAAiC;AACjC,kBAAgB;AAChB,4DAAyD;AACzD,0EAA6D;AAG7D;;;;;GAKG;AACY,KAAK,UAAU,WAAW,CAAC,OAAgC;IACxE,MAAM,QAAQ,GAAG,IAAA,mCAAW,GAAE,CAAC;IAE/B,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,IAAA,+BAAc,EAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAErD,IAAI,cAAc,IAAI,SAAS,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;YAE9C,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,OAA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KAAK,IAAI,SAAS,CAAC,iBAAiB,EAAE,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACvB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport { PackageJson } from \"nx/src/utils/package-json\";\nimport * as pacote from \"pacote\";\nimport \"win-ca\";\nimport { getAccessToken } from \"../utils/authentication\";\nimport { getSettings } from \"../utils/irisAppServerSettings\";\nimport { UnpublishExecutorSchema } from \"./schema\";\n\n/**\n * Unpublish an app from the Trackunit Marketplace.\n *\n * @param {UnpublishExecutorSchema} options options provided to the executor.\n * @returns {Promise<{ success: boolean }>} The result of the unpublish.\n */\nexport default async function runExecutor(options: UnpublishExecutorSchema) {\n const settings = getSettings();\n\n try {\n const tokenData = await getAccessToken(settings.env);\n\n if (\"access_token\" in tokenData) {\n console.log(\"🥳 Successfully authenticated.\");\n\n const manifest = (await pacote.manifest(options.inputPath)) as PackageJson;\n const unpublishResult = await fetch(new URL(manifest.name, settings.repoUrl), {\n method: \"DELETE\",\n headers: {\n Authorization: `Bearer ${tokenData.access_token}`,\n },\n });\n if (unpublishResult.status !== 200) {\n switch (unpublishResult.status) {\n case 401:\n throw new Error(\n `Unpublishing failed due to invalid credentials, Trace ID: ${unpublishResult.headers.get(\"trace-id\")}`\n );\n case 403:\n throw new Error(\n `You are not allowed to unpublish this app, Trace ID: ${unpublishResult.headers.get(\"trace-id\")}`\n );\n case 404:\n throw new Error(\n `The app you are trying to unpublish does not exist, Trace ID: ${unpublishResult.headers.get(\"trace-id\")}`\n );\n default:\n throw new Error(`${unpublishResult.statusText}, Trace ID: ${unpublishResult.headers.get(\"trace-id\")}`);\n }\n }\n\n console.log(\"🥳 Successfully unpublished app.\");\n return { success: true };\n } else if (\"error\" in tokenData) {\n if (tokenData.error === \"expired_token\") {\n throw new Error(\"⌛️ Authentication attempt expired\");\n } else {\n throw new Error(`Error occurred: ${tokenData.error} ${tokenData.error_description}`);\n }\n } else {\n throw new Error(\"Unknown error occurred\");\n }\n } catch (e) {\n console.error(\"❌ \", e);\n return { success: false };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/utils/authentication.ts"],"names":[],"mappings":";;AA2CA,wCA8GC;;AAzJD,+BAA+B;AAC/B,wDAA+B;AAoC/B;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;IACrE,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC5D,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IACpE,0DAA0D;IAC1D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO;YACL,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;YAC9B,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ;YAClC,UAAU,EAAE,CAAC;YACb,KAAK,EAAE,SAAS;SACjB,CAAC;QACF,uFAAuF;QACvF,mCAAmC;IACrC,CAAC;SAAM,IAAI,QAAQ,KAAK,SAAS,EAAE,CAA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AC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport openBrowser from \"open\";\n\nexport interface AuthSettings {\n env: string;\n publicAuthorizationServerBaseUrl: string;\n internalAuthorizationServerBaseUrl: string;\n apiTokensV2BaseUrl: string;\n clientId: string;\n}\n\ninterface OktaError {\n error: string;\n error_description: string;\n}\n\ninterface AuthorizeDataSuccess {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete: string;\n expires_in: number;\n interval: number;\n}\n\ntype AuthorizeData = AuthorizeDataSuccess | OktaError;\n\nexport interface TokenDataSuccess {\n token_type: string;\n expires_in: number;\n access_token: string;\n scope: string;\n id_token: string;\n}\n\ntype TokenData = OktaError | TokenDataSuccess;\n\n/**\n * Authenticate and get access token\n *\n * @param {AuthSettings} env Settings used for authentication\n * @returns {*} {Promise<TokenData>}\n */\nexport async function getAccessToken(env: string): Promise<TokenData> {\n const settings = getAuthSettings(env);\n const clientId = process.env[`TU_CLIENT_ID_${settings.env}`];\n const clientSecret = process.env[`TU_CLIENT_SECRET_${settings.env}`];\n const apiTokenClientId = process.env.TU_API_TOKEN_CLIENT_ID;\n const apiTokenClientSecret = process.env.TU_API_TOKEN_CLIENT_SECRET;\n // use token provided as environment variable if available\n if (process.env.TU_TOKEN) {\n return {\n token_type: \"Bearer\",\n id_token: process.env.TU_TOKEN,\n access_token: process.env.TU_TOKEN,\n expires_in: 0,\n scope: \"unknown\",\n };\n // use client id and secret provided as environment variables to fetch a token directly\n // This is used for CI/CD pipelines\n } else if (clientId !== undefined) {\n if (clientId.trim() === \"\") {\n throw new Error(`Missing environment value: TU_CLIENT_ID_${settings.env}`);\n }\n if (clientSecret === undefined || clientSecret.trim() === \"\") {\n throw new Error(`Missing environment value: TU_CLIENT_SECRET_${settings.env}`);\n }\n\n const tokenParams = new URLSearchParams();\n tokenParams.append(\"client_id\", clientId);\n tokenParams.append(\"client_secret\", clientSecret);\n tokenParams.append(\"grant_type\", \"client_credentials\");\n const scopes = [\"core.iris.app.publish_for_all_accounts\"];\n if (process.env.TU_APPROVE === \"true\") {\n scopes.push(\"core.iris.app.approve\");\n }\n tokenParams.append(\"scope\", scopes.join(\" \"));\n const tokenResponse = await fetch(`${settings.internalAuthorizationServerBaseUrl}/v1/token`, {\n method: \"POST\",\n body: tokenParams,\n });\n return (await tokenResponse.json()) as TokenData;\n // use API Tokens v2 client credentials for external API key based publishing\n } else if (apiTokenClientId !== undefined) {\n if (apiTokenClientId.trim() === \"\") {\n throw new Error(\"Missing environment value: TU_API_TOKEN_CLIENT_ID\");\n }\n if (apiTokenClientSecret === undefined || apiTokenClientSecret.trim() === \"\") {\n throw new Error(\"Missing environment value: TU_API_TOKEN_CLIENT_SECRET\");\n }\n\n const tokenParams = new URLSearchParams();\n tokenParams.append(\"client_id\", apiTokenClientId);\n tokenParams.append(\"client_secret\", apiTokenClientSecret);\n tokenParams.append(\"grant_type\", \"client_credentials\");\n tokenParams.append(\"scope\", \"iris.app.submit\");\n const tokenResponse = await fetch(`${settings.apiTokensV2BaseUrl}/token/v2`, {\n method: \"POST\",\n body: tokenParams,\n });\n return (await tokenResponse.json()) as TokenData;\n // ask the user to authenticated using a browser\n // and fetch a token using the device code flow\n } else {\n const authorizeParams = new URLSearchParams();\n authorizeParams.append(\"client_id\", settings.clientId);\n authorizeParams.append(\"scope\", \"openid profile fms assume iris.app.submit\");\n const authorizeResponse = await fetch(`${settings.publicAuthorizationServerBaseUrl}/v1/device/authorize`, {\n method: \"POST\",\n body: authorizeParams,\n });\n const authorizeData = (await authorizeResponse.json()) as AuthorizeData;\n\n if (\"error\" in authorizeData) {\n throw new Error(`Error occurred: ${authorizeData.error} ${authorizeData.error_description}`);\n } else if (!authorizeData.verification_uri_complete) {\n throw new Error(`Missing verification URI: ${JSON.stringify(authorizeData)}`);\n }\n\n console.log(\n `🔐 Attempting to automatically open the Trackunit authentication page in your default browser...\\n If the browser does not open or you wish to use a different device to authorize this request, open the following URL:\\n\\n ${authorizeData.verification_uri_complete}`\n );\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await ((openBrowser as any).default ? (openBrowser as any).default : openBrowser)(\n authorizeData.verification_uri_complete\n );\n } catch {\n // safe to ignore, since we ask the user to open the URL manually above.\n }\n\n console.log(\"\\n⏳ Waiting for authentication in the browser...\");\n let tokenData: TokenData | null = null;\n do {\n await sleep(authorizeData.interval * 1000);\n if (tokenData && \"error\" in tokenData && tokenData.error === \"slow_down\") {\n await sleep(10000);\n }\n const tokenParams = new URLSearchParams();\n tokenParams.append(\"client_id\", settings.clientId);\n tokenParams.append(\"grant_type\", \"urn:ietf:params:oauth:grant-type:device_code\");\n tokenParams.append(\"device_code\", authorizeData.device_code);\n const tokenResponse = await fetch(`${settings.publicAuthorizationServerBaseUrl}/v1/token`, {\n method: \"POST\",\n body: tokenParams,\n });\n tokenData = (await tokenResponse.json()) as TokenData;\n } while (\n !(\"id_token\" in tokenData) &&\n !(\"error\" in tokenData && tokenData.error !== \"authorization_pending\" && tokenData.error !== \"slow_down\")\n );\n return tokenData;\n }\n}\n\n/**\n *\n */\nfunction getAuthSettings(env: string): AuthSettings {\n switch (env) {\n case \"PROD\":\n return {\n clientId: \"0oamfeklvodROR2ul357\",\n publicAuthorizationServerBaseUrl: \"https://identity.iris.trackunit.com/oauth2/aus2u3jix1dWU7fwt356\",\n internalAuthorizationServerBaseUrl: \"https://identity.iris.trackunit.com/oauth2/aushbxvmpdlWrMnO6357\",\n apiTokensV2BaseUrl: \"https://auth.trackunit.com\",\n env,\n };\n case \"STAGE\":\n return {\n clientId: \"0oa1q2vmx21NcFLOs0h8\",\n publicAuthorizationServerBaseUrl: \"https://identity.stage.iris.trackunit.com/oauth2/aus1owd7wny5YVsU00h8\",\n internalAuthorizationServerBaseUrl: \"https://identity.stage.iris.trackunit.com/oauth2/aus1o484n9xEHT7G50h8\",\n apiTokensV2BaseUrl: \"https://stage.auth.trackunit.com\",\n env,\n };\n case \"DEV\":\n return {\n clientId: \"0oamebigau4RkaqZ6357\",\n publicAuthorizationServerBaseUrl: \"https://identity.dev.iris.trackunit.com/oauth2/ausj7eh9zeiFhLk4m357\",\n internalAuthorizationServerBaseUrl: \"https://identity.dev.iris.trackunit.com/oauth2/aush09l7x4mDGKxLu357\",\n apiTokensV2BaseUrl: \"https://dev.auth.trackunit.com\",\n env,\n };\n case \"LOCAL\":\n return {\n clientId: \"0oamebigau4RkaqZ6357\",\n publicAuthorizationServerBaseUrl: \"https://identity.dev.iris.trackunit.com/oauth2/ausj7eh9zeiFhLk4m357\",\n internalAuthorizationServerBaseUrl: \"https://identity.dev.iris.trackunit.com/oauth2/aush09l7x4mDGKxLu357\",\n apiTokensV2BaseUrl: \"https://dev.auth.trackunit.com\",\n env,\n };\n default:\n throw new Error(`Unknown environment: ${env}`);\n }\n}\n\nfunction sleep(time: number) {\n return new Promise(resolve => setTimeout(resolve, time));\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"irisAppServerSettings.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/utils/irisAppServerSettings.ts"],"names":[],"mappings":";;AAWA,kCAaC;AAhBD;;GAEG;AACH,SAAgB,WAAW;IACzB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,MAAM,CAAC;IACxD,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACtD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,WAAW,EAAE,KAAK,QAAQ,CAAC;IAE3F,OAAO;QACL,WAAW,EAAE,IAAI,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC;QACzC,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC;QAClC,kBAAkB;QAClB,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AC,wBAAwB,GAAG,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC,CAAC","sourcesContent":["export type Settings = {\n approvalUrl: URL;\n repoUrl: URL;\n graphqlInternalUrl: URL;\n env: string;\n devTermsAccept: boolean;\n};\n\n/**\n * Provides the settings for the Iris App server based on the environment.\n */\nexport function getSettings(): Settings {\n const env = process.env.TU_ENV?.toUpperCase() ?? \"PROD\";\n const baseUrl = getBaseUrl(env);\n const graphqlInternalUrl = getGraphqlInternalUrl(env);\n const devTermsAccept = process.env.TU_DEV_TERMS_AND_CONDITIONS?.toLowerCase() === \"accept\";\n\n return {\n approvalUrl: new URL(\"approve/\", baseUrl),\n repoUrl: new URL(\"repo/\", baseUrl),\n graphqlInternalUrl,\n env,\n devTermsAccept,\n };\n}\n\n/**\n * Provides the base URL for the Iris App server based on the environment.\n *\n * @param {string} env The environment to get the base URL for.\n * @returns {URL} The base URL for the Iris App server.\n */\nconst getBaseUrl = (env: string) => {\n switch (env.toUpperCase()) {\n case \"PROD\":\n return new URL(process.env.BASE_URL ?? \"https://iris.trackunit.app/\");\n case \"STAGE\":\n return new URL(process.env.BASE_URL ?? \"https://stage.iris.trackunit.app/\");\n case \"DEV\":\n return new URL(process.env.BASE_URL ?? \"https://dev.iris.trackunit.app/\");\n case \"LOCAL\":\n return new URL(process.env.BASE_URL ?? \"http://localhost:3003/\");\n default:\n throw new Error(`Unknown environment: ${env}`);\n }\n};\n\n/**\n * Provides the URL for the internal GraphQL endpoint based on the environment.\n * Can be overridden by the `GRAPHQL_INTERNAL_URL` environment variable.\n *\n * @param {string} env The environment to get the URL for.\n * @returns {URL} The internal GraphQL URL.\n */\nconst getGraphqlInternalUrl = (env: string) => {\n if (process.env.GRAPHQL_INTERNAL_URL) {\n return new URL(process.env.GRAPHQL_INTERNAL_URL);\n }\n switch (env.toUpperCase()) {\n case \"PROD\":\n return new URL(\"https://prod.awsapi.trackunit.com/public/api/graphql/internal/\");\n case \"STAGE\":\n return new URL(\"https://stage.awsapi.trackunit.com/public/api/graphql/internal/\");\n case \"DEV\":\n return new URL(\"https://dev.awsapi.trackunit.com/public/api/graphql/internal/\");\n case \"LOCAL\":\n return new URL(\"http://localhost:5011/internal\");\n default:\n throw new Error(`Unknown environment: ${env}`);\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../libs/iris-app-sdk/iris-app/src/executors/utils/src/index.js"],"names":[],"mappings":";AAAA,wFAAwF","sourcesContent":["// Empty ts file for webpack to be happy - we generate module federated js files instead\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/ai-agent-sync/generator.ts"],"names":[],"mappings":";;AAoHA,oDAyEC;;AA7LD,uCAAyF;AACzF,+CAAyB;AACzB,0DAAuF;AACvF,mDAA6B;AAC7B,uDAAiC;AACjC,wEAAmE;AACnE,oEAA+D;AAG/D,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAC/C,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AACnD,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;AAChF,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;AAEtE,SAAS,cAAc,CAAC,GAAY,EAAE,GAAW;IAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAI,GAA+B,CAAC,GAAG,CAAC,CAAC;QACpD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACvD,CAAC;IACD,OAAO,SAAS,CA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AAC,CAAC;IAEjC,4EAA4E;IAC5E,MAAM,wBAAwB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACzE,IAAA,sBAAa,EAAC,IAAI,EAAE,wBAAwB,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAEvD,mCAAmC;IACnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;IACtE,IAAA,sBAAa,EAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAE/C,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAExB,4EAA4E;IAC5E,0EAA0E;IAC1E,2EAA2E;IAC3E,0CAA0C;IAC1C,OAAO,GAAG,EAAE;QACV,MAAM,MAAM,GAAG,IAAA,qCAAgB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,eAAM,CAAC,IAAI,CACT,qEAAqE,MAAM,CAAC,MAAM,IAAI;gBACpF,0FAA0F,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { GeneratorCallback, Tree, formatFiles, generateFiles, logger } from \"@nx/devkit\";\nimport * as fs from \"fs\";\nimport { detectPackageManager, getPackageManagerCommand } from \"nx/src/devkit-exports\";\nimport * as path from \"path\";\nimport * as semver from \"semver\";\nimport { getPackageManifest } from \"../utils/get-package-manifest\";\nimport { linkClaudeSkills } from \"../utils/link-claude-skills\";\nimport { AiAgentSyncGeneratorSchema } from \"./schema\";\n\nconst IRIS_APP_PACKAGE = \"@trackunit/iris-app\";\nconst MIGRATIONS_PACKAGE = \"@trackunit/migrations\";\nconst CLAUDE_MD = \"CLAUDE.md\";\nconst CLAUDE_MEMORY_FILES = [CLAUDE_MD, \".claude/CLAUDE.md\", \"CLAUDE.local.md\"];\nconst LEGACY_CLAUDE_MD_DIR = path.join(__dirname, \"legacy-claude-md\");\n\nfunction getStringValue(obj: unknown, key: string): string | undefined {\n if (typeof obj === \"object\" && obj !== null && key in obj) {\n const value = (obj as Record<string, unknown>)[key];\n return typeof value === \"string\" ? value : undefined;\n }\n return undefined;\n}\n\n/**\n * Gets the installed version of @trackunit/iris-app from workspace package.json\n */\nfunction getInstalledSdkVersion(tree: Tree): string | undefined {\n const pkgJson: unknown = JSON.parse(tree.read(\"package.json\", \"utf-8\") ?? \"{}\");\n if (typeof pkgJson !== \"object\" || pkgJson === null) {\n return undefined;\n }\n const pkg = pkgJson as Record<string, unknown>;\n return getStringValue(pkg.dependencies, IRIS_APP_PACKAGE) ?? getStringValue(pkg.devDependencies, IRIS_APP_PACKAGE);\n}\n\n/**\n * Fetches the latest version of @trackunit/iris-app from npm\n */\nasync function getLatestSdkVersion(): Promise<string> {\n const manifest = await getPackageManifest(IRIS_APP_PACKAGE);\n return manifest.version;\n}\n\n/**\n * The single supported way to bring every @trackunit/* dependency up to date.\n * The install of the migrations package is spelled out because a workspace that\n * has never upgraded does not have it, and without it the generator cannot be\n * resolved at all.\n */\nfunction upgradeInstructions(): string {\n const pmc = getPackageManagerCommand(detectPackageManager());\n\n return [\n ` ${pmc.addDev} ${MIGRATIONS_PACKAGE} # only needed once`,\n ` ${pmc.exec} nx g ${MIGRATIONS_PACKAGE}:migrate`,\n ` ${pmc.exec} nx g ${MIGRATIONS_PACKAGE}:run-migrations`,\n ].join(\"\\n\");\n}\n\nfunction normalizeWhitespace(content: string): string {\n return content.replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * Every CLAUDE.md template earlier SDK versions shipped, whitespace-normalized so a\n * workspace formatter's line wrapping or line endings do not hide a match.\n */\nfunction readLegacyClaudeMdTemplates(): Set<string> {\n return new Set(\n fs\n .readdirSync(LEGACY_CLAUDE_MD_DIR)\n .filter(file => file.endsWith(\".md\"))\n .map(file => normalizeWhitespace(fs.readFileSync(path.join(LEGACY_CLAUDE_MD_DIR, file), \"utf-8\")))\n );\n}\n\nfunction importsAgentsMd(content: string): boolean {\n return /^@AGENTS\\.md\\s*$/m.test(content);\n}\n\n/**\n * Earlier SDK versions generated a CLAUDE.md that imported AGENTS.md. Claude Code\n * now reads AGENTS.md directly, so an unmodified copy of that file is removed. Any\n * other CLAUDE.md is the user's and is kept, because AGENTS.md tells users they may\n * add one.\n *\n * Claude Code skips AGENTS.md while any of its memory files exists, so the SDK copy\n * is also kept when another one does: its import is then what loads AGENTS.md.\n */\nfunction removeSdkGeneratedClaudeMd(tree: Tree): void {\n const content = tree.read(CLAUDE_MD, \"utf-8\");\n const otherMemoryFiles = CLAUDE_MEMORY_FILES.filter(file => file !== CLAUDE_MD && tree.exists(file));\n if (\n content !== null &&\n otherMemoryFiles.length === 0 &&\n readLegacyClaudeMdTemplates().has(normalizeWhitespace(content))\n ) {\n tree.delete(CLAUDE_MD);\n }\n\n const presentMemoryFiles = CLAUDE_MEMORY_FILES.filter(file => tree.exists(file));\n if (\n presentMemoryFiles.length > 0 &&\n !presentMemoryFiles.some(file => importsAgentsMd(tree.read(file, \"utf-8\") ?? \"\"))\n ) {\n logger.warn(\n `[iris-app:ai-agent-sync] Claude Code skips AGENTS.md while ${presentMemoryFiles.join(\", \")} exists. ` +\n `Add an @AGENTS.md line to one of them or delete them.`\n );\n }\n}\n\n/**\n * Syncs Cursor skills, AGENTS.md, and AI agent configuration files.\n * Requires the SDK to be at the latest version before running.\n */\nexport async function aiAgentSyncGenerator(\n tree: Tree,\n options: AiAgentSyncGeneratorSchema\n): Promise<GeneratorCallback> {\n // Check SDK version unless skipped\n if (!options.skipVersionCheck) {\n const installedVersion = getInstalledSdkVersion(tree);\n const latestVersion = await getLatestSdkVersion();\n\n if (!installedVersion) {\n throw new Error(`${IRIS_APP_PACKAGE} not found in package.json. Is this an Iris App SDK workspace?`);\n }\n\n const installed = semver.minVersion(installedVersion);\n if (!installed || semver.lt(installed, latestVersion)) {\n throw new Error(\n `${IRIS_APP_PACKAGE} is outdated (installed: ${installedVersion}, latest: ${latestVersion}).\\n\\n` +\n `Upgrade every @trackunit/* dependency first:\\n` +\n `${upgradeInstructions()}\\n\\n` +\n `Then run this generator again.`\n );\n }\n }\n\n // Clean up files that were managed by previous versions.\n const oldManagedFiles = [\n \".cursor/rules/irisx-app-sdk.mdc\",\n \".cursor/rules/rules-index.mdc\",\n \".cursor/rules/structured-development.mdc\",\n \".cursor/rules/browser-irisx-development.mdc\",\n \".cursor/rules/graphql-timeseries.md\",\n \".cursor/rules/graphql-timeseries.mdc\",\n \".cursor/rules/irisx-app-sdk-customfields.md\",\n \".cursor/rules/irisx-app-sdk-customfields.mdc\",\n \".cursor/rules/irisx-app-sdk-graphql.md\",\n \".cursor/rules/irisx-app-sdk-graphql.mdc\",\n \".cursor/rules/react-core-hooks.md\",\n \".cursor/rules/react-core-hooks.mdc\",\n \".cursor/rules/tables-and-sorting.mdc\",\n \".cursor/rules/widget-extensions.md\",\n \".cursor/rules/widget-extensions.mdc\",\n \".cursor/commands/create-app.md\",\n ];\n for (const file of oldManagedFiles) {\n if (tree.exists(file)) {\n tree.delete(file);\n }\n }\n removeSdkGeneratedClaudeMd(tree);\n\n // Copy MCP configuration and agent skills shared with the preset generator.\n const managedFilesTemplatePath = path.join(__dirname, \"../preset/files\");\n generateFiles(tree, managedFilesTemplatePath, \".\", {});\n\n // Copy AGENTS.md to workspace root\n const rootTemplatePath = path.join(__dirname, \"../preset/root-files\");\n generateFiles(tree, rootTemplatePath, \".\", {});\n\n await formatFiles(tree);\n\n // After tree flush, create a symlink at .claude/skills -> ../.agents/skills\n // so Claude Code auto-discovers the same skills Cursor and Codex consume.\n // The Tree API has no symlink primitive, so this runs as a post-generation\n // callback against the actual filesystem.\n return () => {\n const result = linkClaudeSkills(tree.root);\n if (result.status === \"skipped\") {\n logger.warn(\n `[iris-app:ai-agent-sync] Skipped creating .claude/skills symlink: ${result.reason}. ` +\n `Claude Code users may need to create it manually: ln -s ../.agents/skills .claude/skills`\n );\n }\n };\n}\n"]}
|
|
@@ -5,7 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const internal_1 = require("@nx/js/internal");
|
|
7
7
|
const path = tslib_1.__importStar(require("path"));
|
|
8
|
-
const
|
|
8
|
+
const own_package_json_1 = require("../utils/own-package-json/own-package-json");
|
|
9
|
+
const pinned_versions_1 = require("../utils/pinned-versions/pinned-versions");
|
|
9
10
|
const uses_trackunit_eslint_plugin_1 = require("../utils/uses-trackunit-eslint-plugin");
|
|
10
11
|
const write_trackunit_project_eslint_config_1 = require("../utils/write-trackunit-project-eslint-config");
|
|
11
12
|
function normalizeOptions(tree, options) {
|
|
@@ -53,30 +54,21 @@ function addFiles(tree, options, packageJson, useTrackunitLint) {
|
|
|
53
54
|
const IrisAppGenerator = async function (tree, options) {
|
|
54
55
|
const normalizedOptions = normalizeOptions(tree, options);
|
|
55
56
|
const useTrackunitLint = (0, uses_trackunit_eslint_plugin_1.usesTrackunitEslintPlugin)(tree);
|
|
56
|
-
const
|
|
57
|
-
const packageJsonLocally = (0, devkit_1.readJsonFile)(path.join(__dirname, "..", "..", "..", "package.json"));
|
|
57
|
+
const packageJsonLocally = (0, own_package_json_1.readOwnPackageJson)();
|
|
58
58
|
if (options.updatePackageJson) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
const reactComponentsPackageJsonFromNpm = (0, get_package_manifest_1.getPackageManifest)("@trackunit/react-components");
|
|
64
|
-
const reactCoreContextsPackageJsonFromNpm = (0, get_package_manifest_1.getPackageManifest)("@trackunit/react-core-contexts");
|
|
65
|
-
const cssCorePackageJsonFromNpm = (0, get_package_manifest_1.getPackageManifest)("@trackunit/css-core");
|
|
66
|
-
const irisAppApiPackageJsonFromNpm = (0, get_package_manifest_1.getPackageManifest)("@trackunit/iris-app-api");
|
|
59
|
+
// No registry lookup: it would ignore the developer's npm release-age policy.
|
|
60
|
+
// eslint-disable-next-line no-console
|
|
61
|
+
console.log("Keep the SDK current with: npx nx g @trackunit/migrations:migrate");
|
|
67
62
|
const tuDependencies = {
|
|
68
|
-
"@trackunit/react-components": (
|
|
69
|
-
"@trackunit/react-core-contexts": (
|
|
70
|
-
"@trackunit/css-core": (
|
|
71
|
-
"@trackunit/iris-app-api": (
|
|
63
|
+
"@trackunit/react-components": (0, pinned_versions_1.getPinnedVersion)("@trackunit/react-components"),
|
|
64
|
+
"@trackunit/react-core-contexts": (0, pinned_versions_1.getPinnedVersion)("@trackunit/react-core-contexts"),
|
|
65
|
+
"@trackunit/css-core": (0, pinned_versions_1.getPinnedVersion)("@trackunit/css-core"),
|
|
66
|
+
"@trackunit/iris-app-api": (0, pinned_versions_1.getPinnedVersion)("@trackunit/iris-app-api"),
|
|
72
67
|
};
|
|
73
|
-
const irisAppSdkVitePackageJsonFromNpm = (0, get_package_manifest_1.getPackageManifest)("@trackunit/iris-app-sdk-vite");
|
|
74
|
-
const reactCoreContextsTestPackageJsonFromNpm = (0, get_package_manifest_1.getPackageManifest)("@trackunit/react-core-contexts-test");
|
|
75
|
-
const reactViteTestSetupPackageJsonFromNpm = (0, get_package_manifest_1.getPackageManifest)("@trackunit/react-vite-test-setup");
|
|
76
68
|
const tuDevDependencies = {
|
|
77
|
-
"@trackunit/iris-app-sdk-vite": (
|
|
78
|
-
"@trackunit/react-core-contexts-test": (
|
|
79
|
-
"@trackunit/react-vite-test-setup": (
|
|
69
|
+
"@trackunit/iris-app-sdk-vite": (0, pinned_versions_1.getPinnedVersion)("@trackunit/iris-app-sdk-vite"),
|
|
70
|
+
"@trackunit/react-core-contexts-test": (0, pinned_versions_1.getPinnedVersion)("@trackunit/react-core-contexts-test"),
|
|
71
|
+
"@trackunit/react-vite-test-setup": (0, pinned_versions_1.getPinnedVersion)("@trackunit/react-vite-test-setup"),
|
|
80
72
|
};
|
|
81
73
|
(0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
82
74
|
...tuDependencies,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/create/generator.ts"],"names":[],"mappings":";;;;AAAA,uCAWoB;AACpB,8CAA8C;AAC9C,mDAA6B;AAC7B,iFAAqG;AACrG,8EAA4E;AAC5E,wFAAkF;AAClF,0GAAmG;AAWnG,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,sBAAW,EAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,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,CACf,IAAU,EACV,OAAyB,EACzB,WAAkC,EA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CAAC,IAAI,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACxE,sDAAsD;IACtD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;IAE7C,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhC,sCAAsC;QACtC,OAAO,CAAC,GAAG,CACT,wGAAwG,CACzG,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AA9HW,QAAA,gBAAgB,oBA8H3B","sourcesContent":["import {\n addDependenciesToPackageJson,\n addProjectConfiguration,\n formatFiles,\n generateFiles,\n getWorkspaceLayout,\n installPackagesTask,\n names,\n offsetFromRoot,\n Tree,\n updateJson,\n} from \"@nx/devkit\";\nimport { getNpmScope } from \"@nx/js/internal\";\nimport * as path from \"path\";\nimport { readOwnPackageJson, type OwnPackageJson } from \"../utils/own-package-json/own-package-json\";\nimport { getPinnedVersion } from \"../utils/pinned-versions/pinned-versions\";\nimport { usesTrackunitEslintPlugin } from \"../utils/uses-trackunit-eslint-plugin\";\nimport { writeTrackunitProjectEslintConfig } from \"../utils/write-trackunit-project-eslint-config\";\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 = getNpmScope(tree);\n if (!npmScope) {\n throw new Error(\"Could not find npm scope in package.json\");\n }\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(\n tree: Tree,\n options: NormalizedSchema,\n packageJson: OwnPackageJson | null,\n useTrackunitLint: boolean\n) {\n const nodeVersion = packageJson?.engines?.node ?? \">=20.x\";\n const templateOptions = {\n ...options,\n ...names(options.name),\n offsetFromRoot: offsetFromRoot(options.projectRoot),\n template: \"\",\n nodeVersion,\n };\n generateFiles(tree, path.join(__dirname, \"files\"), options.projectRoot, templateOptions);\n if (useTrackunitLint) {\n // Must run after \"files\" so it replaces the default eslint.config.cjs.\n writeTrackunitProjectEslintConfig(tree, options.projectRoot, options.toNxRoot);\n }\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 useTrackunitLint = usesTrackunitEslintPlugin(tree);\n\n const packageJsonLocally = readOwnPackageJson();\n\n if (options.updatePackageJson) {\n // No registry lookup: it would ignore the developer's npm release-age policy.\n // eslint-disable-next-line no-console\n console.log(\"Keep the SDK current with: npx nx g @trackunit/migrations:migrate\");\n\n const tuDependencies = {\n \"@trackunit/react-components\": getPinnedVersion(\"@trackunit/react-components\"),\n \"@trackunit/react-core-contexts\": getPinnedVersion(\"@trackunit/react-core-contexts\"),\n \"@trackunit/css-core\": getPinnedVersion(\"@trackunit/css-core\"),\n \"@trackunit/iris-app-api\": getPinnedVersion(\"@trackunit/iris-app-api\"),\n };\n\n const tuDevDependencies = {\n \"@trackunit/iris-app-sdk-vite\": getPinnedVersion(\"@trackunit/iris-app-sdk-vite\"),\n \"@trackunit/react-core-contexts-test\": getPinnedVersion(\"@trackunit/react-core-contexts-test\"),\n \"@trackunit/react-vite-test-setup\": getPinnedVersion(\"@trackunit/react-vite-test-setup\"),\n };\n\n addDependenciesToPackageJson(\n tree,\n {\n ...tuDependencies,\n \"@apollo/client\": \"3.14.1\",\n graphql: \"16.10.0\",\n \"@tanstack/react-router\": \"1.170.39\",\n tslib: \"2.4.0\",\n react: \"19.3.0\",\n \"react-dom\": \"19.3.0\",\n \"single-spa-react\": \"5.1.4\",\n },\n {\n ...tuDevDependencies,\n nx: \"23.3.0\",\n \"@nx/react\": \"23.3.0\",\n \"@nx/workspace\": \"23.3.0\",\n \"@nx/devkit\": \"23.3.0\",\n \"@nx/eslint-plugin\": \"23.3.0\",\n \"@types/react\": \"19.3.0\",\n eslint: \"9.33.0\",\n \"eslint-plugin-react-hooks\": \"7.0.1\",\n \"eslint-plugin-react\": \"7.37.5\",\n \"eslint-plugin-import\": \"2.32.0\",\n \"eslint-plugin-jsx-a11y\": \"6.10.2\",\n \"typescript-eslint\": \"8.71.2\",\n typescript: \"6.0.2\",\n }\n );\n\n updateJson(tree, \"package.json\", packageJson => {\n packageJson.overrides = {\n react: \"19.3.0\", // to avoid resolution warnings when running npm install\n \"react-dom\": \"19.3.0\", // fix resolution warnings and test\n \"zod-validation-error\": \"4.0.2\",\n };\n return packageJson;\n });\n }\n addProjectConfiguration(tree, normalizedOptions.projectName, {\n root: normalizedOptions.projectRoot,\n projectType: \"application\",\n sourceRoot: `${normalizedOptions.projectRoot}/src`,\n ...(useTrackunitLint ? { tags: [\"type:app\"] } : {}),\n targets: {\n build: {\n executor: \"@trackunit/iris-app-sdk-vite:build\",\n dependsOn: [\n {\n target: \"build\",\n params: \"forward\",\n dependencies: true,\n },\n ],\n options: {\n viteConfig: `${normalizedOptions.projectRoot}/vite.config.ts`,\n outputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n outputs: [\"{options.outputPath}\"],\n },\n serve: {\n executor: \"@trackunit/iris-app-sdk-vite:serve\",\n options: {\n viteConfig: `${normalizedOptions.projectRoot}/vite.config.ts`,\n },\n outputs: [\"{options.outputPath}\"],\n },\n submitApp: {\n executor: \"@trackunit/iris-app:submit\",\n dependsOn: [\"build\"],\n options: {\n inputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n outputs: [`{workspaceRoot}/dist/${normalizedOptions.projectRoot}`],\n },\n unpublishApp: {\n executor: \"@trackunit/iris-app:unpublish\",\n options: {\n inputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n dependsOn: [\n {\n target: \"build\",\n },\n ],\n outputs: [`{workspaceRoot}/dist/${normalizedOptions.projectRoot}`],\n },\n },\n });\n addFiles(tree, normalizedOptions, packageJsonLocally, useTrackunitLint);\n // enforcing engine versions specified in package.json\n tree.write(\".npmrc\", \"engine-strict=true\\n\");\n\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n\n // eslint-disable-next-line no-console\n console.log(\n \"🥳 Successfully created an Iris App - review the iris-app-manifest.ts and start adding app extensions!\"\n );\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/extend/dependencies.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEU,QAAA,eAAe,GAAG;IAC7B,wBAAwB,EAAE,UAAU;IACpC,YAAY,EAAE,QAAQ;IACtB,kBAAkB,EAAE,OAAO;CAC5B,CAAC;AAEW,QAAA,gBAAgB,GAAG;IAC9B,UAAU,EAAE,QAAQ;IACpB,YAAY,EAAE,QAAQ;IACtB,sBAAsB,EAAE,SAAS;IACjC,2BAA2B,EAAE,QAAQ;IACrC,wBAAwB,EAAE,QAAQ;IAClC,sBAAsB,EAAE,OAAO;IAC/B,2BAA2B,EAAE,SAAS;IACtC,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,OAAO;IACb,qBAAqB,EAAE,QAAQ;IAC/B,MAAM,EAAE,SAAS;CAClB,CAAC","sourcesContent":["/*\n * Use this file to maintain the version of single-spa and related dependencies.\n * Versions in here should be in sync with the versions in manager package.json.\n * If the test fails, update this file to reflect the version in manager package.json file.\n */\n\nexport const spaDependencies = {\n \"@tanstack/react-router\": \"1.114.29\",\n \"single-spa\": \"^5.9.5\",\n \"single-spa-react\": \"5.1.4\",\n};\n\nexport const testDependencies = {\n \"@nx/vite\": \"23.3.0\",\n \"@nx/vitest\": \"23.3.0\",\n \"@testing-library/dom\": \"^10.4.2\",\n \"@testing-library/jest-dom\": \"^6.9.1\",\n \"@testing-library/react\": \"16.3.3\",\n \"@vitejs/plugin-react\": \"6.1.0\",\n \"@vitest/coverage-istanbul\": \"^4.1.12\",\n jsdom: \"^26.1.0\",\n vite: \"8.3.4\",\n \"vite-tsconfig-paths\": \"^6.1.1\",\n vitest: \"^4.1.12\",\n};\n"]}
|
|
@@ -9,11 +9,10 @@ const internal_1 = require("@nx/js/internal");
|
|
|
9
9
|
const react_1 = require("@nx/react");
|
|
10
10
|
const iris_app_api_1 = require("@trackunit/iris-app-api");
|
|
11
11
|
const react_graphql_tools_1 = require("@trackunit/react-graphql-tools");
|
|
12
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
13
12
|
const path = tslib_1.__importStar(require("path"));
|
|
14
13
|
const string_ts_1 = require("string-ts");
|
|
15
14
|
const ts_morph_1 = require("ts-morph");
|
|
16
|
-
const
|
|
15
|
+
const pinned_versions_1 = require("../utils/pinned-versions/pinned-versions");
|
|
17
16
|
const uses_trackunit_eslint_plugin_1 = require("../utils/uses-trackunit-eslint-plugin");
|
|
18
17
|
const write_trackunit_project_eslint_config_1 = require("../utils/write-trackunit-project-eslint-config");
|
|
19
18
|
const dependencies_1 = require("./dependencies");
|
|
@@ -55,7 +54,6 @@ const addServersideGraphql = async (tree, options) => {
|
|
|
55
54
|
});
|
|
56
55
|
};
|
|
57
56
|
exports.addServersideGraphql = addServersideGraphql;
|
|
58
|
-
const getPackageVersion = async (packageName) => (await (0, get_package_manifest_1.getPackageManifest)(packageName)).version;
|
|
59
57
|
function normalizeOptions(tree, options) {
|
|
60
58
|
const name = (0, devkit_1.names)(options.name).fileName;
|
|
61
59
|
const projectDirectory = options.directory ? `${(0, devkit_1.names)(options.directory).fileName}/${name}` : name;
|
|
@@ -112,11 +110,11 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
112
110
|
if (normalizedOptions.updatePackageJson) {
|
|
113
111
|
const uiExtensionDependencies = iris_app_api_1.nonUiExtensionTypes.includes(irisAppExtensionType)
|
|
114
112
|
? {}
|
|
115
|
-
: { "@trackunit/iris-app-runtime-core":
|
|
113
|
+
: { "@trackunit/iris-app-runtime-core": (0, pinned_versions_1.getPinnedVersion)("@trackunit/iris-app-runtime-core") };
|
|
116
114
|
(0, devkit_1.addDependenciesToPackageJson)(tree, uiExtensionDependencies, {
|
|
117
115
|
...dependencies_1.spaDependencies,
|
|
118
116
|
...dependencies_1.testDependencies,
|
|
119
|
-
"@trackunit/react-vite-test-setup":
|
|
117
|
+
"@trackunit/react-vite-test-setup": (0, pinned_versions_1.getPinnedVersion)("@trackunit/react-vite-test-setup"),
|
|
120
118
|
});
|
|
121
119
|
}
|
|
122
120
|
const schema = {
|
|
@@ -173,8 +171,10 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
173
171
|
esModuleInterop: true,
|
|
174
172
|
};
|
|
175
173
|
}
|
|
174
|
+
// Bug fix: prefix "./" (SDK-576). Root cause: with TypeScript 6 and no `baseUrl` in the generated
|
|
175
|
+
// workspace, non-relative `paths` entries are rejected (TS5090) and break type-checked builds.
|
|
176
176
|
tsConfigBase.compilerOptions.paths[normalizedOptions.importPath] = [
|
|
177
|
-
|
|
177
|
+
`./${(0, devkit_1.joinPathFragments)(normalizedOptions.projectRoot, "extension-manifest.ts")}`,
|
|
178
178
|
];
|
|
179
179
|
return tsConfigBase;
|
|
180
180
|
});
|
|
@@ -235,7 +235,7 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
235
235
|
projectName: normalizedOptions.projectName,
|
|
236
236
|
projectRoot: normalizedOptions.projectRoot,
|
|
237
237
|
className: (0, devkit_1.names)(normalizedOptions.name).className,
|
|
238
|
-
serversideUtilsVersion:
|
|
238
|
+
serversideUtilsVersion: (0, pinned_versions_1.getPinnedVersion)("@trackunit/serverside-utils"),
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
//TODO: Change the following to update the manifest in the virtual Tree - not on the file system.
|
|
@@ -293,35 +293,27 @@ const IrisAppExtensionGenerator = async function (tree, options) {
|
|
|
293
293
|
};
|
|
294
294
|
};
|
|
295
295
|
exports.IrisAppExtensionGenerator = IrisAppExtensionGenerator;
|
|
296
|
+
const IRIS_APP_MANIFEST_FILE = "iris-app-manifest.ts";
|
|
297
|
+
/**
|
|
298
|
+
* The Iris apps in the workspace, as paths relative to the apps directory: an app either sits directly in a folder
|
|
299
|
+
* of it or one level further down, and is recognised by its `iris-app-manifest.ts`. Reads the Tree, not the disk.
|
|
300
|
+
*/
|
|
301
|
+
const findIrisApps = (tree) => {
|
|
302
|
+
const { appsDir } = (0, devkit_1.getWorkspaceLayout)(tree);
|
|
303
|
+
const directoriesIn = (dir) => tree.children(dir).filter(name => !tree.isFile((0, devkit_1.joinPathFragments)(dir, name)));
|
|
304
|
+
const hasManifest = (dir) => tree.isFile((0, devkit_1.joinPathFragments)(dir, IRIS_APP_MANIFEST_FILE));
|
|
305
|
+
return directoriesIn(appsDir).flatMap(folder => {
|
|
306
|
+
const folderPath = (0, devkit_1.joinPathFragments)(appsDir, folder);
|
|
307
|
+
return hasManifest(folderPath)
|
|
308
|
+
? [folder]
|
|
309
|
+
: directoriesIn(folderPath)
|
|
310
|
+
.filter(subFolder => hasManifest((0, devkit_1.joinPathFragments)(folderPath, subFolder)))
|
|
311
|
+
.map(subFolder => (0, devkit_1.joinPathFragments)(folder, subFolder));
|
|
312
|
+
});
|
|
313
|
+
};
|
|
296
314
|
const updateAppName = async (tree, options) => {
|
|
297
315
|
if (!options.app) {
|
|
298
|
-
const
|
|
299
|
-
.readdirSync((0, devkit_1.getWorkspaceLayout)(tree).appsDir, { withFileTypes: true })
|
|
300
|
-
.filter(item => item.isDirectory());
|
|
301
|
-
const tileApps = [];
|
|
302
|
-
folders.forEach(folder => {
|
|
303
|
-
const irisAppManifest = fs
|
|
304
|
-
.readdirSync(`${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${folder.name}`, { withFileTypes: true })
|
|
305
|
-
.find(item => item.name === "iris-app-manifest.ts");
|
|
306
|
-
if (irisAppManifest) {
|
|
307
|
-
tileApps.push(folder.name);
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
const subFolders = fs
|
|
311
|
-
.readdirSync(path.join((0, devkit_1.getWorkspaceLayout)(tree).appsDir, folder.name), { withFileTypes: true })
|
|
312
|
-
.filter(item => item.isDirectory());
|
|
313
|
-
subFolders.forEach(subFolder => {
|
|
314
|
-
const subDirIrisAppManifest = fs
|
|
315
|
-
.readdirSync(`${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${folder.name}/${subFolder.name}`, {
|
|
316
|
-
withFileTypes: true,
|
|
317
|
-
})
|
|
318
|
-
.find(item => item.name === "iris-app-manifest.ts");
|
|
319
|
-
if (subDirIrisAppManifest) {
|
|
320
|
-
tileApps.push(path.join(folder.name, subFolder.name));
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
});
|
|
316
|
+
const tileApps = findIrisApps(tree);
|
|
325
317
|
if (tileApps.length === 1) {
|
|
326
318
|
options.app = tileApps[0] || "<Missing iris app name>";
|
|
327
319
|
}
|