@embroider/compat 3.8.1 → 4.0.0-alpha.0
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/babel.js +1 -0
- package/package.json +21 -15
- package/src/audit/babel-visitor.js +7 -1
- package/src/audit/babel-visitor.js.map +1 -1
- package/src/audit/build.js.map +1 -1
- package/src/audit/options.d.ts +2 -1
- package/src/audit/options.js.map +1 -1
- package/src/audit.d.ts +7 -57
- package/src/audit.js +101 -301
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.js +19 -18
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/babel.d.ts +17 -0
- package/src/babel.js +146 -0
- package/src/babel.js.map +1 -0
- package/src/compat-adapters/@ember-data/store.d.ts +1 -5
- package/src/compat-adapters/@ember-data/store.js +3 -15
- package/src/compat-adapters/@ember-data/store.js.map +1 -1
- package/src/compat-adapters/active-model-adapter.d.ts +1 -1
- package/src/compat-adapters/ember-asset-loader.d.ts +1 -1
- package/src/compat-adapters/ember-cli-addon-docs.d.ts +1 -1
- package/src/compat-adapters/ember-cli-fastboot.js +0 -1
- package/src/compat-adapters/ember-cli-fastboot.js.map +1 -1
- package/src/compat-adapters/ember-cli-mirage.js +0 -1
- package/src/compat-adapters/ember-cli-mirage.js.map +1 -1
- package/src/compat-adapters/ember-decorators.d.ts +1 -1
- package/src/compat-adapters/ember-fetch.d.ts +5 -0
- package/src/compat-adapters/{ember-macro-helpers.js → ember-fetch.js} +5 -4
- package/src/compat-adapters/ember-fetch.js.map +1 -0
- package/src/compat-adapters/ember-percy.d.ts +1 -1
- package/src/compat-adapters/ember-resolver.d.ts +4 -0
- package/src/compat-adapters/ember-resolver.js +21 -0
- package/src/compat-adapters/ember-resolver.js.map +1 -0
- package/src/compat-adapters/ember-scroll-modifiers.d.ts +1 -1
- package/src/compat-adapters/ember-source.d.ts +3 -6
- package/src/compat-adapters/ember-source.js +26 -41
- package/src/compat-adapters/ember-source.js.map +1 -1
- package/src/compat-adapters/ember-test-selectors.d.ts +1 -1
- package/src/compat-addons.js +1 -1
- package/src/compat-addons.js.map +1 -1
- package/src/compat-app-builder.d.ts +9 -67
- package/src/compat-app-builder.js +108 -1299
- package/src/compat-app-builder.js.map +1 -1
- package/src/compat-app.d.ts +4 -22
- package/src/compat-app.js +78 -221
- package/src/compat-app.js.map +1 -1
- package/src/content-for-config.d.ts +11 -0
- package/src/content-for-config.js +66 -0
- package/src/content-for-config.js.map +1 -0
- package/src/default-pipeline.d.ts +4 -5
- package/src/default-pipeline.js +21 -46
- package/src/default-pipeline.js.map +1 -1
- package/src/dependency-rules.d.ts +1 -0
- package/src/dependency-rules.js +19 -11
- package/src/dependency-rules.js.map +1 -1
- package/src/detect-babel-plugins.d.ts +1 -0
- package/src/detect-babel-plugins.js +14 -0
- package/src/detect-babel-plugins.js.map +1 -1
- package/src/http-audit.d.ts +13 -0
- package/src/http-audit.js +60 -0
- package/src/http-audit.js.map +1 -0
- package/src/index.d.ts +2 -2
- package/src/index.js +3 -4
- package/src/index.js.map +1 -1
- package/src/module-visitor.d.ts +52 -0
- package/src/module-visitor.js +285 -0
- package/src/module-visitor.js.map +1 -0
- package/src/options.d.ts +4 -43
- package/src/options.js +35 -8
- package/src/options.js.map +1 -1
- package/src/resolver-transform.d.ts +1 -1
- package/src/resolver-transform.js +71 -43
- package/src/resolver-transform.js.map +1 -1
- package/src/standalone-addon-build.js +6 -15
- package/src/standalone-addon-build.js.map +1 -1
- package/src/v1-addon.js +6 -35
- package/src/v1-addon.js.map +1 -1
- package/src/v1-config.d.ts +0 -8
- package/src/v1-config.js +1 -51
- package/src/v1-config.js.map +1 -1
- package/src/audit-cli.d.ts +0 -2
- package/src/audit-cli.js +0 -150
- package/src/audit-cli.js.map +0 -1
- package/src/compat-adapters/@ember-data/debug.d.ts +0 -6
- package/src/compat-adapters/@ember-data/debug.js +0 -22
- package/src/compat-adapters/@ember-data/debug.js.map +0 -1
- package/src/compat-adapters/ember-macro-helpers.d.ts +0 -4
- package/src/compat-adapters/ember-macro-helpers.js.map +0 -1
- package/src/rename-require-plugin.d.ts +0 -1
- package/src/rename-require-plugin.js +0 -15
- package/src/rename-require-plugin.js.map +0 -1
- package/src/sync-dir.d.ts +0 -8
- package/src/sync-dir.js +0 -68
- package/src/sync-dir.js.map +0 -1
- package/src/template-tag-codemod.d.ts +0 -13
- package/src/template-tag-codemod.js +0 -302
- package/src/template-tag-codemod.js.map +0 -1
- package/src/v1-appboot.d.ts +0 -14
- package/src/v1-appboot.js +0 -47
- package/src/v1-appboot.js.map +0 -1
package/src/audit-cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-cli.js","sourceRoot":"","sources":["audit-cli.ts"],"names":[],"mappings":";;;;;;AAEA,uCAAqE;AACrE,+BAA+B;AAC/B,wDAAgC;AAEhC,mCAA4D;AAE5D,gFAAgF;AAChF,2DAA2D;AAC3D,MAAM,EAAE,OAAO,EAAE,GAAG,eAEnB,CAAC;AAEF,SAAS,MAAM;IACb,OAAO,IAAA,eAAK,EAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAChC,OAAO,CACN,IAAI,EACJ,qDAAqD,EACrD,KAAK,CAAC,EAAE;QACN,OAAO,KAAK;aACT,MAAM,CAAC,OAAO,EAAE;YACf,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,0CAA0C;YACvD,OAAO,EAAE,KAAK;SACf,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,8BAA8B;YAC3C,OAAO,EAAE,KAAK;SACf,CAAC;aACD,MAAM,CAAC,aAAa,EAAE;YACrB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,sBAAsB;YACnC,OAAO,EAAE,KAAK;SACf,CAAC;aACD,MAAM,CAAC,MAAM,EA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iE;QACjE,OAAO,OAAO,CAAC,IAAA,cAAO,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,MAA0B,EAAE,OAAqB;IACpE,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACnD,OAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBACvC,OAAO,CACL,QAAQ,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO;oBACpC,QAAQ,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;oBAClC,QAAQ,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,CACvC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,QAAgB,EAAE,OAAqB;IAC3D,IAAI,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACxC,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB,CAAC,CAAC,CAAC;IACJ,IAAA,wBAAa,EAAC,QAAQ,EAAE,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync, readJSONSync, writeFileSync } from 'fs-extra';\nimport { resolve } from 'path';\nimport yargs from 'yargs/yargs';\nimport type { Finding } from './audit';\nimport { Audit, AuditResults, isBuildError } from './audit';\n\n// slightly wacky because yargs types don't cover this, but you can't access the\n// other documented place to find `hideBin` on node < 12.17\nconst { hideBin } = yargs as any as {\n hideBin(argv: readonly string[]): readonly string[];\n};\n\nfunction runCLI() {\n return yargs(hideBin(process.argv))\n .command(\n '$0',\n 'audit your app for embroider compatibility problems',\n yargs => {\n return yargs\n .option('debug', {\n alias: 'd',\n type: 'boolean',\n description: 'Add debug logging about the audit itself',\n default: false,\n })\n .option('json', {\n alias: 'j',\n type: 'boolean',\n description: 'Print results in JSON format',\n default: false,\n })\n .option('reuse-build', {\n alias: 'r',\n type: 'boolean',\n description: 'Reuse previous build',\n default: false,\n })\n .option('load', {\n alias: 'l',\n type: 'string',\n description: 'Load previous audit results from a JSON file instead of running a new audit',\n })\n .option('save', {\n alias: 's',\n type: 'string',\n description: 'Save audit results as a JSON file.',\n })\n .option('app', {\n type: 'string',\n description: 'Path to your app',\n default: process.cwd(),\n })\n .option('filter', {\n type: 'string',\n description:\n 'Path to a JS file that describes which findings to silence. Generate the initial file using `--create-filter`.',\n })\n .option('create-filter', {\n type: 'string',\n description:\n 'Path to a JS file where we will create a filter that will silence all your current findings. Pass it back into future audits via --filter',\n })\n .fail(function (_, err, _yargs) {\n if (isBuildError(err)) {\n process.stderr.write(err.message + '\\n');\n } else {\n console.error(err);\n }\n process.exit(1);\n });\n },\n async options => {\n let filter = loadFilter(options);\n let results: AuditResults;\n if (options.load) {\n results = new AuditResults();\n Object.assign(results, readJSONSync(options.load));\n } else {\n results = await Audit.run(options);\n }\n if (options.save) {\n writeFileSync(options.save, JSON.stringify(results, null, 2));\n }\n applyFilter(filter, results);\n if (options.json) {\n process.stdout.write(JSON.stringify(results, null, 2) + '\\n');\n } else {\n process.stdout.write(results.humanReadable());\n }\n if (options['create-filter']) {\n createFilter(options['create-filter'], results);\n }\n process.exit(results.perfect ? 0 : 1);\n }\n )\n .command(\n 'pretty',\n 'format JSON audit results as pretty human-readable results',\n yargs => {\n return yargs.option('filter', {\n type: 'string',\n description:\n 'Path to a JS file that describes which findings to silence. Generate the file using `embroider-compat-audit acknowledge`',\n });\n },\n async options => {\n let filter = loadFilter(options);\n let results = new AuditResults();\n // process.stdin.fd is a documented public API. The Node typings don't\n // seem to know about it.\n Object.assign(results, JSON.parse(readFileSync((process.stdin as any).fd, 'utf8')));\n applyFilter(filter, results);\n process.stdout.write(results.humanReadable());\n process.exit(0);\n }\n )\n .command(\n 'acknowledge',\n 'Pipe your audit JSON to this command to generate a filter file that will silence the current issues. Pass the filter file into your next audit via --filter. Delete findings out of the filter file as you address them.',\n yargs => yargs,\n async () => {\n let results = new AuditResults();\n // process.stdin.fd is a documented public API. The Node typings don't\n // seem to know about it.\n Object.assign(results, JSON.parse(readFileSync((process.stdin as any).fd, 'utf8')));\n let findings = results.findings.map(f => ({\n filename: f.filename,\n message: f.message,\n detail: f.detail,\n }));\n process.stdout.write(`module.exports = ${JSON.stringify({ findings }, null, 2)};\\n`);\n process.exit(0);\n }\n ).argv;\n}\n\nif (require.main === module) {\n runCLI();\n}\n\ntype Filter = { findings: Omit<Finding, 'codeFrame'>[] };\n\nfunction loadFilter(options: { filter: string | undefined }): Filter | undefined {\n if (options.filter) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(resolve(options.filter));\n }\n}\n\nfunction applyFilter(filter: Filter | undefined, results: AuditResults) {\n if (filter) {\n results.findings = results.findings.filter(finding => {\n return !filter!.findings.find(filtered => {\n return (\n filtered.message === finding.message &&\n filtered.detail === finding.detail &&\n filtered.filename === finding.filename\n );\n });\n });\n }\n}\n\nfunction createFilter(filename: string, results: AuditResults) {\n let findings = results.findings.map(f => ({\n filename: f.filename,\n message: f.message,\n detail: f.detail,\n }));\n writeFileSync(filename, `module.exports = ${JSON.stringify({ findings }, null, 2)};\\n`);\n}\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const v1_addon_1 = __importDefault(require("../../v1-addon"));
|
|
7
|
-
const semver_1 = __importDefault(require("semver"));
|
|
8
|
-
class EmberDataDebug extends v1_addon_1.default {
|
|
9
|
-
get packageMeta() {
|
|
10
|
-
var _a;
|
|
11
|
-
let meta = super.packageMeta;
|
|
12
|
-
// See also the compat-adapter for @ember-data/store where we make this an
|
|
13
|
-
// implicit-module.
|
|
14
|
-
meta.externals = [...((_a = meta.externals) !== null && _a !== void 0 ? _a : []), '@ember-data/store'];
|
|
15
|
-
return meta;
|
|
16
|
-
}
|
|
17
|
-
static shouldApplyAdapter(addonInstance) {
|
|
18
|
-
return semver_1.default.lt(addonInstance.pkg.version, '4.11.1');
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = EmberDataDebug;
|
|
22
|
-
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["debug.ts"],"names":[],"mappings":";;;;;AACA,8DAAqC;AACrC,oDAA4B;AAE5B,MAAqB,cAAe,SAAQ,kBAAO;IACjD,IAAI,WAAW;;QACb,IAAI,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;QAE7B,0EAA0E;QAC1E,mBAAmB;QACnB,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,SAAS,mCAAI,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAElE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,aAAkB;QAC1C,OAAO,gBAAM,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF;AAdD,iCAcC","sourcesContent":["import type { AddonMeta } from '@embroider/core';\nimport V1Addon from '../../v1-addon';\nimport semver from 'semver';\n\nexport default class EmberDataDebug extends V1Addon {\n get packageMeta(): Partial<AddonMeta> {\n let meta = super.packageMeta;\n\n // See also the compat-adapter for @ember-data/store where we make this an\n // implicit-module.\n meta.externals = [...(meta.externals ?? []), '@ember-data/store'];\n\n return meta;\n }\n\n static shouldApplyAdapter(addonInstance: any) {\n return semver.lt(addonInstance.pkg.version, '4.11.1');\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ember-macro-helpers.js","sourceRoot":"","sources":["ember-macro-helpers.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAElC,eAAqB,SAAQ,kBAAO;IAClC,IAAI,WAAW;QACb,IAAI,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AATD,4BASC","sourcesContent":["import V1Addon from '../v1-addon';\n\nexport default class extends V1Addon {\n get packageMeta() {\n let meta = super.packageMeta;\n if (!meta.externals) {\n meta.externals = [];\n }\n meta.externals.push('./-computed-store');\n return meta;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function inlineHBSTransform(): unknown;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = inlineHBSTransform;
|
|
4
|
-
function inlineHBSTransform() {
|
|
5
|
-
return {
|
|
6
|
-
visitor: {
|
|
7
|
-
ImportDefaultSpecifier(path) {
|
|
8
|
-
if (path.node.local.name === 'require') {
|
|
9
|
-
path.scope.rename('require');
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=rename-require-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rename-require-plugin.js","sourceRoot":"","sources":["rename-require-plugin.ts"],"names":[],"mappings":";;AAGA,qCAUC;AAVD,SAAwB,kBAAkB;IACxC,OAAO;QACL,OAAO,EAAE;YACP,sBAAsB,CAAC,IAAwC;gBAC7D,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;oBACvC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { types as t } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\n\nexport default function inlineHBSTransform(): unknown {\n return {\n visitor: {\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n if (path.node.local.name === 'require') {\n path.scope.rename('require');\n }\n },\n },\n };\n}\n"]}
|
package/src/sync-dir.d.ts
DELETED
package/src/sync-dir.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SyncDir = void 0;
|
|
7
|
-
const assert_never_1 = __importDefault(require("assert-never"));
|
|
8
|
-
const fs_tree_diff_1 = __importDefault(require("fs-tree-diff"));
|
|
9
|
-
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
10
|
-
const path_1 = require("path");
|
|
11
|
-
const fs_extra_1 = require("fs-extra");
|
|
12
|
-
// mirrors the changes in the src dir to the dest dir, while tracking the
|
|
13
|
-
// current set of files present. If dest is undefined, it only tracks the set of
|
|
14
|
-
// files without mirroring the changes to anywhere
|
|
15
|
-
class SyncDir {
|
|
16
|
-
constructor(src, dest) {
|
|
17
|
-
this.src = src;
|
|
18
|
-
this.dest = dest;
|
|
19
|
-
this.prev = new fs_tree_diff_1.default();
|
|
20
|
-
this.files = new Set();
|
|
21
|
-
}
|
|
22
|
-
update() {
|
|
23
|
-
let next = new fs_tree_diff_1.default({
|
|
24
|
-
entries: walk_sync_1.default.entries(this.src),
|
|
25
|
-
});
|
|
26
|
-
for (let [operation, relativePath] of this.prev.calculatePatch(next)) {
|
|
27
|
-
let outputPath;
|
|
28
|
-
if (this.dest) {
|
|
29
|
-
outputPath = (0, path_1.resolve)(this.dest, relativePath);
|
|
30
|
-
}
|
|
31
|
-
switch (operation) {
|
|
32
|
-
case 'unlink':
|
|
33
|
-
if (outputPath) {
|
|
34
|
-
(0, fs_extra_1.unlinkSync)(outputPath);
|
|
35
|
-
}
|
|
36
|
-
this.files.delete(relativePath);
|
|
37
|
-
break;
|
|
38
|
-
case 'rmdir':
|
|
39
|
-
if (outputPath) {
|
|
40
|
-
(0, fs_extra_1.rmdirSync)(outputPath);
|
|
41
|
-
}
|
|
42
|
-
break;
|
|
43
|
-
case 'mkdir':
|
|
44
|
-
if (outputPath) {
|
|
45
|
-
(0, fs_extra_1.mkdirpSync)(outputPath);
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
case 'change':
|
|
49
|
-
if (outputPath) {
|
|
50
|
-
(0, fs_extra_1.removeSync)(outputPath);
|
|
51
|
-
(0, fs_extra_1.copySync)((0, path_1.resolve)(this.src, relativePath), outputPath, { dereference: true });
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
case 'create':
|
|
55
|
-
if (outputPath) {
|
|
56
|
-
(0, fs_extra_1.copySync)((0, path_1.resolve)(this.src, relativePath), outputPath, { dereference: true });
|
|
57
|
-
}
|
|
58
|
-
this.files.add(relativePath);
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
(0, assert_never_1.default)(operation);
|
|
62
|
-
}
|
|
63
|
-
this.prev = next;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.SyncDir = SyncDir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oBACD,MAAM;gBACR,KAAK,OAAO;oBACV,IAAI,UAAU,EAAE,CAAC;wBACf,IAAA,qBAAU,EAAC,UAAU,CAAC,CAAC;oBACzB,CAAC;oBACD,MAAM;gBACR,KAAK,QAAQ;oBACX,IAAI,UAAU,EAAE,CAAC;wBACf,IAAA,qBAAU,EAAC,UAAU,CAAC,CAAC;wBACvB,IAAA,mBAAQ,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC/E,CAAC;oBACD,MAAM;gBACR,KAAK,QAAQ;oBACX,IAAI,UAAU,EAAE,CAAC;wBACf,IAAA,mBAAQ,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC/E,CAAC;oBACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;oBAC7B,MAAM;gBACR;oBACE,IAAA,sBAAW,EAAC,SAAS,CAAC,CAAC;YAC3B,CAAC;YACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAlDD,0BAkDC","sourcesContent":["import assertNever from 'assert-never';\nimport FSTree from 'fs-tree-diff';\nimport walkSync from 'walk-sync';\nimport { resolve } from 'path';\nimport { copySync, mkdirpSync, removeSync, rmdirSync, unlinkSync } from 'fs-extra';\n\n// mirrors the changes in the src dir to the dest dir, while tracking the\n// current set of files present. If dest is undefined, it only tracks the set of\n// files without mirroring the changes to anywhere\nexport class SyncDir {\n private prev: FSTree = new FSTree();\n readonly files: Set<string> = new Set();\n\n constructor(private src: string, private dest: string | undefined) {}\n\n update(): void {\n let next = new FSTree({\n entries: walkSync.entries(this.src),\n });\n for (let [operation, relativePath] of this.prev.calculatePatch(next)) {\n let outputPath: string | undefined;\n if (this.dest) {\n outputPath = resolve(this.dest, relativePath);\n }\n switch (operation) {\n case 'unlink':\n if (outputPath) {\n unlinkSync(outputPath);\n }\n this.files.delete(relativePath);\n break;\n case 'rmdir':\n if (outputPath) {\n rmdirSync(outputPath);\n }\n break;\n case 'mkdir':\n if (outputPath) {\n mkdirpSync(outputPath);\n }\n break;\n case 'change':\n if (outputPath) {\n removeSync(outputPath);\n copySync(resolve(this.src, relativePath), outputPath, { dereference: true });\n }\n break;\n case 'create':\n if (outputPath) {\n copySync(resolve(this.src, relativePath), outputPath, { dereference: true });\n }\n this.files.add(relativePath);\n break;\n default:\n assertNever(operation);\n }\n this.prev = next;\n }\n }\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EmberAppInstance } from '@embroider/core';
|
|
2
|
-
import type { Node } from 'broccoli-node-api';
|
|
3
|
-
import { type ExternalNameHint } from './resolver-transform';
|
|
4
|
-
export interface TemplateTagCodemodOptions {
|
|
5
|
-
shouldTransformPath: (outputPath: string) => boolean;
|
|
6
|
-
nameHint: ExternalNameHint;
|
|
7
|
-
dryRun: boolean;
|
|
8
|
-
}
|
|
9
|
-
export default function templateTagCodemod(emberApp: EmberAppInstance, { shouldTransformPath, nameHint, dryRun, }?: {
|
|
10
|
-
shouldTransformPath?: ((outputPath: string) => boolean) | undefined;
|
|
11
|
-
nameHint?: ExternalNameHint | undefined;
|
|
12
|
-
dryRun?: boolean | undefined;
|
|
13
|
-
}): Node;
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = templateTagCodemod;
|
|
7
|
-
const default_pipeline_1 = __importDefault(require("./default-pipeline"));
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const fs_1 = require("fs");
|
|
10
|
-
const broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
|
|
11
|
-
const core_1 = require("@babel/core");
|
|
12
|
-
const core_2 = require("@embroider/core");
|
|
13
|
-
const resolver_transform_1 = __importDefault(require("./resolver-transform"));
|
|
14
|
-
const child_process_1 = require("child_process");
|
|
15
|
-
const core_3 = require("@embroider/core");
|
|
16
|
-
function templateTagCodemod(emberApp, { shouldTransformPath = (() => true), nameHint = (path => {
|
|
17
|
-
return path
|
|
18
|
-
.split('/')
|
|
19
|
-
.map(part => part
|
|
20
|
-
.split('-')
|
|
21
|
-
// capitalize first letter
|
|
22
|
-
.map(inner_part => inner_part.charAt(0).toUpperCase() + inner_part.slice(1))
|
|
23
|
-
.join(''))
|
|
24
|
-
.join('_');
|
|
25
|
-
}), dryRun = false, } = {}) {
|
|
26
|
-
return new TemplateTagCodemodPlugin([
|
|
27
|
-
(0, default_pipeline_1.default)(emberApp, undefined, {
|
|
28
|
-
staticAddonTrees: true,
|
|
29
|
-
staticAddonTestSupportTrees: true,
|
|
30
|
-
staticInvokables: true,
|
|
31
|
-
staticEmberSource: true,
|
|
32
|
-
amdCompatibility: {
|
|
33
|
-
es: [],
|
|
34
|
-
},
|
|
35
|
-
}),
|
|
36
|
-
], { shouldTransformPath, nameHint, dryRun });
|
|
37
|
-
}
|
|
38
|
-
const TEMPLATE_ONLY_MARKER = `import templateOnlyComponent from '@ember/component/template-only';`;
|
|
39
|
-
const TEMPLATE_COLOCATION_MARKER = /\/\* import __COLOCATED_TEMPLATE__ from (.*) \*\//;
|
|
40
|
-
class TemplateTagCodemodPlugin extends broccoli_plugin_1.default {
|
|
41
|
-
constructor(inputNodes, options) {
|
|
42
|
-
super(inputNodes, {
|
|
43
|
-
name: 'TemplateTagCodemodPlugin',
|
|
44
|
-
});
|
|
45
|
-
this.options = options;
|
|
46
|
-
}
|
|
47
|
-
async build() {
|
|
48
|
-
var _a, _b;
|
|
49
|
-
function* walkSync(dir) {
|
|
50
|
-
const files = (0, fs_1.readdirSync)(dir);
|
|
51
|
-
for (const file of files) {
|
|
52
|
-
const pathToFile = (0, path_1.join)(dir, file);
|
|
53
|
-
const isDirectory = (0, fs_1.statSync)(pathToFile).isDirectory();
|
|
54
|
-
if (isDirectory) {
|
|
55
|
-
yield* walkSync(pathToFile);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
yield pathToFile;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
this.inputPaths[0];
|
|
63
|
-
const tmp_path = (0, fs_1.readFileSync)(this.inputPaths[0] + '/.stage2-output').toLocaleString();
|
|
64
|
-
const compatPattern = /#embroider_compat\/(?<type>[^\/]+)\/(?<rest>.*)/;
|
|
65
|
-
const resolver = new core_2.ResolverLoader(process.cwd()).resolver;
|
|
66
|
-
const hbs_file_test = /[\\/]rewritten-app[\\/]components[\\/].*\.hbs$/;
|
|
67
|
-
// locate ember-source for the host app so we know which version to insert builtIns for
|
|
68
|
-
const emberSourceEntrypoint = require.resolve('ember-source', { paths: [process.cwd()] });
|
|
69
|
-
const emberVersion = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(emberSourceEntrypoint, '../../package.json')).toString()).version;
|
|
70
|
-
const ember_template_compiler = resolver.nodeResolve('ember-source/vendor/ember/ember-template-compiler', (0, path_1.resolve)((0, core_3.locateEmbroiderWorkingDir)(process.cwd()), 'rewritten-app', 'package.json'));
|
|
71
|
-
if (ember_template_compiler.type === 'not_found') {
|
|
72
|
-
throw 'This will not ever be true';
|
|
73
|
-
}
|
|
74
|
-
const embroider_compat_path = require.resolve('@embroider/compat', { paths: [process.cwd()] });
|
|
75
|
-
const babel_plugin_ember_template_compilation = require.resolve('babel-plugin-ember-template-compilation', {
|
|
76
|
-
paths: [embroider_compat_path],
|
|
77
|
-
});
|
|
78
|
-
const babel_plugin_syntax_decorators = require.resolve('@babel/plugin-syntax-decorators', {
|
|
79
|
-
paths: [embroider_compat_path],
|
|
80
|
-
});
|
|
81
|
-
const babel_plugin_syntax_typescript = require.resolve('@babel/plugin-syntax-typescript', {
|
|
82
|
-
paths: [embroider_compat_path],
|
|
83
|
-
});
|
|
84
|
-
const resolver_transform = (0, resolver_transform_1.default)({
|
|
85
|
-
appRoot: process.cwd(),
|
|
86
|
-
emberVersion: emberVersion,
|
|
87
|
-
externalNameHint: this.options.nameHint,
|
|
88
|
-
});
|
|
89
|
-
for await (const current_file of walkSync(tmp_path)) {
|
|
90
|
-
if (hbs_file_test.test(current_file) && this.options.shouldTransformPath(current_file)) {
|
|
91
|
-
const template_file_src = (0, fs_1.readFileSync)(current_file).toLocaleString();
|
|
92
|
-
// run the template transformations using embroider resolver information
|
|
93
|
-
// to replace template values with js import syntax used in g(j/t)s
|
|
94
|
-
let transformed_source = (_b = (_a = (0, core_1.transformSync)((0, core_2.hbsToJS)(template_file_src), {
|
|
95
|
-
plugins: [
|
|
96
|
-
[
|
|
97
|
-
babel_plugin_ember_template_compilation,
|
|
98
|
-
{
|
|
99
|
-
compilerPath: ember_template_compiler.filename,
|
|
100
|
-
transforms: [resolver_transform],
|
|
101
|
-
targetFormat: 'hbs',
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
],
|
|
105
|
-
filename: current_file,
|
|
106
|
-
})) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '';
|
|
107
|
-
// using transformSync to parse and traverse in one go
|
|
108
|
-
// we're only extracting the transformed template information from previous step
|
|
109
|
-
// and preserving it for later assembly in the backing class
|
|
110
|
-
const import_bucket = [];
|
|
111
|
-
let template_tag_value = '';
|
|
112
|
-
(0, core_1.transformSync)(transformed_source, {
|
|
113
|
-
plugins: [
|
|
114
|
-
function template_tag_extractor() {
|
|
115
|
-
return {
|
|
116
|
-
visitor: {
|
|
117
|
-
ImportDeclaration(import_declaration) {
|
|
118
|
-
const extractor = import_declaration.node.source.value.match(compatPattern);
|
|
119
|
-
if (extractor) {
|
|
120
|
-
const result = resolver.nodeResolve(extractor[0], current_file);
|
|
121
|
-
if (result.type === 'real') {
|
|
122
|
-
// find package there the resolver is pointing
|
|
123
|
-
const owner_package = resolver.packageCache.ownerOfFile(result.filename);
|
|
124
|
-
let relative_import_path = (0, path_1.relative)(owner_package.root, result.filename);
|
|
125
|
-
// for addons strip off appPublicationDir from relative path
|
|
126
|
-
// we do this on app files as well as they don't contain the
|
|
127
|
-
// path that we strip off
|
|
128
|
-
// this makes sure that ambiguous imports get properly attributed
|
|
129
|
-
relative_import_path = relative_import_path.replace('_app_/', '');
|
|
130
|
-
// remove the extension to match what a developer would normally write
|
|
131
|
-
relative_import_path = relative_import_path.slice(0, -(0, path_1.extname)(relative_import_path).length);
|
|
132
|
-
// change import path to real one
|
|
133
|
-
import_declaration.node.source.value = owner_package.name + '/' + relative_import_path;
|
|
134
|
-
import_bucket.push(import_declaration);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else if (import_declaration.node.source.value.indexOf('@ember/template-compilation') === -1) {
|
|
138
|
-
import_bucket.push(import_declaration);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
CallExpression(path) {
|
|
142
|
-
// reverse of hbs to js
|
|
143
|
-
// extract the template string to put into template tag in backing class
|
|
144
|
-
if ('name' in path.node.callee &&
|
|
145
|
-
path.node.callee.name === 'precompileTemplate' &&
|
|
146
|
-
path.node.arguments &&
|
|
147
|
-
'value' in path.node.arguments[0]) {
|
|
148
|
-
template_tag_value = `<template>\n\t${path.node.arguments[0].value}\n</template>`;
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
});
|
|
156
|
-
//find backing class
|
|
157
|
-
const backing_class_resolution = resolver.nodeResolve('#embroider_compat/' + (0, path_1.relative)(tmp_path, current_file).replace(/[\\]/g, '/').slice(0, -4), tmp_path);
|
|
158
|
-
const backing_class_filename = 'filename' in backing_class_resolution ? backing_class_resolution.filename : '';
|
|
159
|
-
// this can be either a generated js file in case of template only components
|
|
160
|
-
// the js or ts file depending on what the app is configured
|
|
161
|
-
const backing_class_src = (0, fs_1.readFileSync)(backing_class_filename).toString();
|
|
162
|
-
const is_typescript = (0, path_1.extname)(backing_class_filename) === '.ts';
|
|
163
|
-
let insert_imports_byte_count = null;
|
|
164
|
-
let insert_template_byte_count = null;
|
|
165
|
-
const is_template_only = backing_class_src.indexOf(TEMPLATE_ONLY_MARKER) !== -1;
|
|
166
|
-
// we parse the backing class to find the insert points for imports and template
|
|
167
|
-
(0, core_1.transformSync)(backing_class_src, {
|
|
168
|
-
plugins: [
|
|
169
|
-
[
|
|
170
|
-
is_typescript ? babel_plugin_syntax_typescript : babel_plugin_syntax_decorators,
|
|
171
|
-
{ decoratorsBeforeExport: true },
|
|
172
|
-
],
|
|
173
|
-
function glimmer_syntax_creator( /* babel */) {
|
|
174
|
-
return {
|
|
175
|
-
name: 'test',
|
|
176
|
-
visitor: {
|
|
177
|
-
ImportDeclaration(import_declaration) {
|
|
178
|
-
insert_imports_byte_count = import_declaration.node.end;
|
|
179
|
-
},
|
|
180
|
-
ExportDefaultDeclaration(path) {
|
|
181
|
-
// convention is that we have a default export for each component
|
|
182
|
-
// we look for the closing bracket of the class body
|
|
183
|
-
path.traverse({
|
|
184
|
-
ClassBody(path) {
|
|
185
|
-
// we substract 1 to find the byte right before the final closing bracket `}`
|
|
186
|
-
// this is the default insert point for template tag though it could live anywhere inside the class body
|
|
187
|
-
// possible future point to add option for putting template first thing in class
|
|
188
|
-
insert_template_byte_count = path.node.end ? path.node.end - 1 : 0;
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
});
|
|
197
|
-
// list of imports needed by the previous hbs template extracted in second step
|
|
198
|
-
const hbs_template_required_imports = import_bucket.join('\n');
|
|
199
|
-
// we extracted all we needed from transformed_source so we switch to the second phase
|
|
200
|
-
// transforming the backing class into what will be our final output
|
|
201
|
-
transformed_source = backing_class_src;
|
|
202
|
-
if (is_template_only) {
|
|
203
|
-
// because we can't inject a comment as the default export
|
|
204
|
-
// we replace the known exported string
|
|
205
|
-
transformed_source = transformed_source.replace('templateOnlyComponent()', template_tag_value);
|
|
206
|
-
// we clean known markers from generated files
|
|
207
|
-
transformed_source = transformed_source.replace(TEMPLATE_ONLY_MARKER, hbs_template_required_imports);
|
|
208
|
-
transformed_source = transformed_source.replace(TEMPLATE_COLOCATION_MARKER, '');
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
// we modify the source from end to start in order to keep our byte counts valid through the transforms
|
|
212
|
-
if (insert_template_byte_count) {
|
|
213
|
-
// first we split the backing class at the byte count we found during backing class parsing
|
|
214
|
-
// then concat the string back together adding the transformed template in the middle
|
|
215
|
-
transformed_source =
|
|
216
|
-
transformed_source.substring(0, insert_template_byte_count) +
|
|
217
|
-
'\n' +
|
|
218
|
-
template_tag_value +
|
|
219
|
-
'\n' +
|
|
220
|
-
transformed_source.substring(insert_template_byte_count, transformed_source.length);
|
|
221
|
-
}
|
|
222
|
-
if (insert_imports_byte_count) {
|
|
223
|
-
// first we split the backing class at the byte count we found during backing class parsing
|
|
224
|
-
// then concat the string back together adding the transformed template in the middle
|
|
225
|
-
transformed_source =
|
|
226
|
-
transformed_source.substring(0, insert_imports_byte_count) +
|
|
227
|
-
'\n' +
|
|
228
|
-
hbs_template_required_imports +
|
|
229
|
-
'\n' +
|
|
230
|
-
transformed_source.substring(insert_imports_byte_count, transformed_source.length);
|
|
231
|
-
}
|
|
232
|
-
transformed_source = transformed_source.replace(TEMPLATE_COLOCATION_MARKER, '');
|
|
233
|
-
}
|
|
234
|
-
const dryRun = this.options.dryRun ? '--dry-run' : '';
|
|
235
|
-
// work out original file path in app tree
|
|
236
|
-
const app_relative_path = (0, path_1.join)('app', (0, path_1.relative)(tmp_path, current_file));
|
|
237
|
-
const new_file_path = app_relative_path.slice(0, -4) + (is_typescript ? '.gts' : '.gjs');
|
|
238
|
-
// write glimmer file out
|
|
239
|
-
if (this.options.dryRun) {
|
|
240
|
-
console.log('Write new file', new_file_path, transformed_source);
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(process.cwd(), new_file_path), transformed_source, { flag: 'wx+' });
|
|
244
|
-
}
|
|
245
|
-
// git rm old files (js/ts if exists + hbs)
|
|
246
|
-
let rm_hbs = await execute(`git rm ${app_relative_path} ${dryRun}`, {
|
|
247
|
-
pwd: process.cwd(),
|
|
248
|
-
});
|
|
249
|
-
console.log(rm_hbs.output);
|
|
250
|
-
if (!is_template_only) {
|
|
251
|
-
// remove backing class only if it's not a template only component
|
|
252
|
-
// resolve relative path to rewritten-app
|
|
253
|
-
const app_relative_path = (0, path_1.join)('app', (0, path_1.relative)(tmp_path, backing_class_filename));
|
|
254
|
-
let rm_js = await execute(`git rm ${app_relative_path} ${dryRun}`, {
|
|
255
|
-
pwd: process.cwd(),
|
|
256
|
-
});
|
|
257
|
-
console.log(rm_js.output);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
async function execute(shellCommand, opts) {
|
|
264
|
-
let env;
|
|
265
|
-
if (opts === null || opts === void 0 ? void 0 : opts.env) {
|
|
266
|
-
env = { ...process.env, ...opts.env };
|
|
267
|
-
}
|
|
268
|
-
let child = (0, child_process_1.spawn)(shellCommand, {
|
|
269
|
-
stdio: ['inherit', 'pipe', 'pipe'],
|
|
270
|
-
cwd: opts === null || opts === void 0 ? void 0 : opts.pwd,
|
|
271
|
-
shell: true,
|
|
272
|
-
env,
|
|
273
|
-
});
|
|
274
|
-
let stderrBuffer = [];
|
|
275
|
-
let stdoutBuffer = [];
|
|
276
|
-
let combinedBuffer = [];
|
|
277
|
-
child.stderr.on('data', data => {
|
|
278
|
-
stderrBuffer.push(data);
|
|
279
|
-
combinedBuffer.push(data);
|
|
280
|
-
});
|
|
281
|
-
child.stdout.on('data', data => {
|
|
282
|
-
stdoutBuffer.push(data);
|
|
283
|
-
combinedBuffer.push(data);
|
|
284
|
-
});
|
|
285
|
-
return new Promise(resolve => {
|
|
286
|
-
child.on('close', (exitCode) => {
|
|
287
|
-
resolve({
|
|
288
|
-
exitCode,
|
|
289
|
-
get stdout() {
|
|
290
|
-
return stdoutBuffer.join('');
|
|
291
|
-
},
|
|
292
|
-
get stderr() {
|
|
293
|
-
return stderrBuffer.join('');
|
|
294
|
-
},
|
|
295
|
-
get output() {
|
|
296
|
-
return combinedBuffer.join('');
|
|
297
|
-
},
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
//# sourceMappingURL=template-tag-codemod.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-tag-codemod.js","sourceRoot":"","sources":["template-tag-codemod.ts"],"names":[],"mappings":";;;;;AAoBA,qCAiCC;AArDD,0EAA4D;AAG5D,+BAAwD;AAGxD,2BAAwE;AACxE,sEAAqC;AACrC,sCAA4C;AAC5C,0CAA0D;AAC1D,8EAAgF;AAChF,iDAAsC;AACtC,0CAA4D;AAQ5D,SAAwB,kBAAkB,CACxC,QAA0B,EAC1B,EACE,mBAAmB,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAqD,EACtF,QAAQ,GAAG,CAAC,IAAI,CAAC,EAAE;IACjB,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,IAAI,CAAC,EAAE,CACV,IAAI;SACD,KAAK,CAAC,GAAG,CAAC;QACX,0BAA0B;SACzB,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3E,IAAI,CAAC,EAAE,CAAC,CACZ;SACA,IAAI,CAAC,GAAG,CAAC,CAAC;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GAAG,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG;QACd,KAAK,EAAE,IAAI;QACX,GAAG;KACJ,CAAC,CAAC;IACH,IAAI,YAAY,GAAa,EAAE,CAAC;IAChC,IAAI,YAAY,GAAa,EAAE,CAAC;IAChC,IAAI,cAAc,GAAa,EAAE,CAAC;IAClC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;QAC7B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;QAC7B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,QAAgB,EAAE,EAAE;YACrC,OAAO,CAAC;gBACN,QAAQ;gBACR,IAAI,MAAM;oBACR,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/B,CAAC;gBACD,IAAI,MAAM;oBACR,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/B,CAAC;gBACD,IAAI,MAAM;oBACR,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACjC,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { default as compatBuild } from './default-pipeline';\nimport type { EmberAppInstance } from '@embroider/core';\nimport type { Node, InputNode } from 'broccoli-node-api';\nimport { join, relative, resolve, extname } from 'path';\nimport type { types as t } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport { statSync, readdirSync, readFileSync, writeFileSync } from 'fs';\nimport Plugin from 'broccoli-plugin';\nimport { transformSync } from '@babel/core';\nimport { hbsToJS, ResolverLoader } from '@embroider/core';\nimport ResolverTransform, { type ExternalNameHint } from './resolver-transform';\nimport { spawn } from 'child_process';\nimport { locateEmbroiderWorkingDir } from '@embroider/core';\n\nexport interface TemplateTagCodemodOptions {\n shouldTransformPath: (outputPath: string) => boolean;\n nameHint: ExternalNameHint;\n dryRun: boolean;\n}\n\nexport default function templateTagCodemod(\n emberApp: EmberAppInstance,\n {\n shouldTransformPath = (() => true) as TemplateTagCodemodOptions['shouldTransformPath'],\n nameHint = (path => {\n return path\n .split('/')\n .map(part =>\n part\n .split('-')\n // capitalize first letter\n .map(inner_part => inner_part.charAt(0).toUpperCase() + inner_part.slice(1))\n .join('')\n )\n .join('_');\n }) as TemplateTagCodemodOptions['nameHint'],\n dryRun = false,\n } = {}\n): Node {\n return new TemplateTagCodemodPlugin(\n [\n compatBuild(emberApp, undefined, {\n staticAddonTrees: true,\n staticAddonTestSupportTrees: true,\n staticInvokables: true,\n staticEmberSource: true,\n amdCompatibility: {\n es: [],\n },\n }),\n ],\n { shouldTransformPath, nameHint, dryRun }\n );\n}\n\nconst TEMPLATE_ONLY_MARKER = `import templateOnlyComponent from '@ember/component/template-only';`;\nconst TEMPLATE_COLOCATION_MARKER = /\\/\\* import __COLOCATED_TEMPLATE__ from (.*) \\*\\//;\n\nclass TemplateTagCodemodPlugin extends Plugin {\n constructor(inputNodes: InputNode[], readonly options: TemplateTagCodemodOptions) {\n super(inputNodes, {\n name: 'TemplateTagCodemodPlugin',\n });\n }\n async build() {\n function* walkSync(dir: string): Generator<string> {\n const files = readdirSync(dir);\n\n for (const file of files) {\n const pathToFile = join(dir, file);\n const isDirectory = statSync(pathToFile).isDirectory();\n if (isDirectory) {\n yield* walkSync(pathToFile);\n } else {\n yield pathToFile;\n }\n }\n }\n this.inputPaths[0];\n const tmp_path = readFileSync(this.inputPaths[0] + '/.stage2-output').toLocaleString();\n const compatPattern = /#embroider_compat\\/(?<type>[^\\/]+)\\/(?<rest>.*)/;\n const resolver = new ResolverLoader(process.cwd()).resolver;\n const hbs_file_test = /[\\\\/]rewritten-app[\\\\/]components[\\\\/].*\\.hbs$/;\n // locate ember-source for the host app so we know which version to insert builtIns for\n const emberSourceEntrypoint = require.resolve('ember-source', { paths: [process.cwd()] });\n const emberVersion = JSON.parse(readFileSync(join(emberSourceEntrypoint, '../../package.json')).toString()).version;\n\n const ember_template_compiler = resolver.nodeResolve(\n 'ember-source/vendor/ember/ember-template-compiler',\n resolve(locateEmbroiderWorkingDir(process.cwd()), 'rewritten-app', 'package.json')\n );\n if (ember_template_compiler.type === 'not_found') {\n throw 'This will not ever be true';\n }\n\n const embroider_compat_path = require.resolve('@embroider/compat', { paths: [process.cwd()] });\n const babel_plugin_ember_template_compilation = require.resolve('babel-plugin-ember-template-compilation', {\n paths: [embroider_compat_path],\n });\n const babel_plugin_syntax_decorators = require.resolve('@babel/plugin-syntax-decorators', {\n paths: [embroider_compat_path],\n });\n const babel_plugin_syntax_typescript = require.resolve('@babel/plugin-syntax-typescript', {\n paths: [embroider_compat_path],\n });\n const resolver_transform = ResolverTransform({\n appRoot: process.cwd(),\n emberVersion: emberVersion,\n externalNameHint: this.options.nameHint,\n });\n\n for await (const current_file of walkSync(tmp_path)) {\n if (hbs_file_test.test(current_file) && this.options.shouldTransformPath(current_file)) {\n const template_file_src = readFileSync(current_file).toLocaleString();\n\n // run the template transformations using embroider resolver information\n // to replace template values with js import syntax used in g(j/t)s\n let transformed_source =\n transformSync(hbsToJS(template_file_src), {\n plugins: [\n [\n babel_plugin_ember_template_compilation,\n {\n compilerPath: ember_template_compiler.filename,\n transforms: [resolver_transform],\n targetFormat: 'hbs',\n },\n ],\n ],\n filename: current_file,\n })?.code ?? '';\n\n // using transformSync to parse and traverse in one go\n // we're only extracting the transformed template information from previous step\n // and preserving it for later assembly in the backing class\n const import_bucket: NodePath<t.ImportDeclaration>[] = [];\n let template_tag_value = '';\n transformSync(transformed_source, {\n plugins: [\n function template_tag_extractor(): unknown {\n return {\n visitor: {\n ImportDeclaration(import_declaration: NodePath<t.ImportDeclaration>) {\n const extractor = import_declaration.node.source.value.match(compatPattern);\n if (extractor) {\n const result = resolver.nodeResolve(extractor[0], current_file);\n if (result.type === 'real') {\n // find package there the resolver is pointing\n const owner_package = resolver.packageCache.ownerOfFile(result.filename);\n let relative_import_path = relative(owner_package!.root, result.filename);\n // for addons strip off appPublicationDir from relative path\n // we do this on app files as well as they don't contain the\n // path that we strip off\n // this makes sure that ambiguous imports get properly attributed\n relative_import_path = relative_import_path.replace('_app_/', '');\n // remove the extension to match what a developer would normally write\n relative_import_path = relative_import_path.slice(0, -extname(relative_import_path).length);\n\n // change import path to real one\n import_declaration.node.source.value = owner_package!.name + '/' + relative_import_path;\n import_bucket.push(import_declaration);\n }\n } else if (import_declaration.node.source.value.indexOf('@ember/template-compilation') === -1) {\n import_bucket.push(import_declaration);\n }\n },\n CallExpression(path: NodePath<t.CallExpression>) {\n // reverse of hbs to js\n // extract the template string to put into template tag in backing class\n if (\n 'name' in path.node.callee &&\n path.node.callee.name === 'precompileTemplate' &&\n path.node.arguments &&\n 'value' in path.node.arguments[0]\n ) {\n template_tag_value = `<template>\\n\\t${path.node.arguments[0].value}\\n</template>`;\n }\n },\n },\n };\n },\n ],\n });\n\n //find backing class\n const backing_class_resolution = resolver.nodeResolve(\n '#embroider_compat/' + relative(tmp_path, current_file).replace(/[\\\\]/g, '/').slice(0, -4),\n tmp_path\n );\n\n const backing_class_filename = 'filename' in backing_class_resolution ? backing_class_resolution.filename : '';\n // this can be either a generated js file in case of template only components\n // the js or ts file depending on what the app is configured\n const backing_class_src = readFileSync(backing_class_filename).toString();\n\n const is_typescript = extname(backing_class_filename) === '.ts';\n\n let insert_imports_byte_count = null;\n let insert_template_byte_count = null;\n\n const is_template_only = backing_class_src.indexOf(TEMPLATE_ONLY_MARKER) !== -1;\n\n // we parse the backing class to find the insert points for imports and template\n transformSync(backing_class_src, {\n plugins: [\n [\n is_typescript ? babel_plugin_syntax_typescript : babel_plugin_syntax_decorators,\n { decoratorsBeforeExport: true },\n ],\n function glimmer_syntax_creator(/* babel */): unknown {\n return {\n name: 'test',\n visitor: {\n ImportDeclaration(import_declaration: NodePath<t.ImportDeclaration>) {\n insert_imports_byte_count = import_declaration.node.end;\n },\n ExportDefaultDeclaration(path: NodePath<t.ExportDefaultDeclaration>) {\n // convention is that we have a default export for each component\n // we look for the closing bracket of the class body\n path.traverse({\n ClassBody(path) {\n // we substract 1 to find the byte right before the final closing bracket `}`\n // this is the default insert point for template tag though it could live anywhere inside the class body\n // possible future point to add option for putting template first thing in class\n insert_template_byte_count = path.node.end ? path.node.end - 1 : 0;\n },\n });\n },\n },\n };\n },\n ],\n });\n\n // list of imports needed by the previous hbs template extracted in second step\n const hbs_template_required_imports = import_bucket.join('\\n');\n\n // we extracted all we needed from transformed_source so we switch to the second phase\n // transforming the backing class into what will be our final output\n transformed_source = backing_class_src;\n if (is_template_only) {\n // because we can't inject a comment as the default export\n // we replace the known exported string\n transformed_source = transformed_source.replace('templateOnlyComponent()', template_tag_value);\n // we clean known markers from generated files\n transformed_source = transformed_source.replace(TEMPLATE_ONLY_MARKER, hbs_template_required_imports);\n transformed_source = transformed_source.replace(TEMPLATE_COLOCATION_MARKER, '');\n } else {\n // we modify the source from end to start in order to keep our byte counts valid through the transforms\n if (insert_template_byte_count) {\n // first we split the backing class at the byte count we found during backing class parsing\n // then concat the string back together adding the transformed template in the middle\n transformed_source =\n transformed_source.substring(0, insert_template_byte_count) +\n '\\n' +\n template_tag_value +\n '\\n' +\n transformed_source.substring(insert_template_byte_count, transformed_source.length);\n }\n if (insert_imports_byte_count) {\n // first we split the backing class at the byte count we found during backing class parsing\n // then concat the string back together adding the transformed template in the middle\n transformed_source =\n transformed_source.substring(0, insert_imports_byte_count) +\n '\\n' +\n hbs_template_required_imports +\n '\\n' +\n transformed_source.substring(insert_imports_byte_count, transformed_source.length);\n }\n transformed_source = transformed_source.replace(TEMPLATE_COLOCATION_MARKER, '');\n }\n\n const dryRun = this.options.dryRun ? '--dry-run' : '';\n // work out original file path in app tree\n const app_relative_path = join('app', relative(tmp_path, current_file));\n const new_file_path = app_relative_path.slice(0, -4) + (is_typescript ? '.gts' : '.gjs');\n\n // write glimmer file out\n if (this.options.dryRun) {\n console.log('Write new file', new_file_path, transformed_source);\n } else {\n writeFileSync(join(process.cwd(), new_file_path), transformed_source, { flag: 'wx+' });\n }\n\n // git rm old files (js/ts if exists + hbs)\n let rm_hbs = await execute(`git rm ${app_relative_path} ${dryRun}`, {\n pwd: process.cwd(),\n });\n console.log(rm_hbs.output);\n\n if (!is_template_only) {\n // remove backing class only if it's not a template only component\n // resolve relative path to rewritten-app\n const app_relative_path = join('app', relative(tmp_path, backing_class_filename));\n let rm_js = await execute(`git rm ${app_relative_path} ${dryRun}`, {\n pwd: process.cwd(),\n });\n\n console.log(rm_js.output);\n }\n }\n }\n }\n}\n\nasync function execute(\n shellCommand: string,\n opts?: { env?: Record<string, string>; pwd?: string }\n): Promise<{\n exitCode: number;\n stderr: string;\n stdout: string;\n output: string;\n}> {\n let env: Record<string, string | undefined> | undefined;\n if (opts?.env) {\n env = { ...process.env, ...opts.env };\n }\n let child = spawn(shellCommand, {\n stdio: ['inherit', 'pipe', 'pipe'],\n cwd: opts?.pwd,\n shell: true,\n env,\n });\n let stderrBuffer: string[] = [];\n let stdoutBuffer: string[] = [];\n let combinedBuffer: string[] = [];\n child.stderr.on('data', data => {\n stderrBuffer.push(data);\n combinedBuffer.push(data);\n });\n child.stdout.on('data', data => {\n stdoutBuffer.push(data);\n combinedBuffer.push(data);\n });\n return new Promise(resolve => {\n child.on('close', (exitCode: number) => {\n resolve({\n exitCode,\n get stdout() {\n return stdoutBuffer.join('');\n },\n get stderr() {\n return stderrBuffer.join('');\n },\n get output() {\n return combinedBuffer.join('');\n },\n });\n });\n });\n}\n"]}
|
package/src/v1-appboot.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Plugin from 'broccoli-plugin';
|
|
2
|
-
import type { Node } from 'broccoli-node-api';
|
|
3
|
-
export declare class WriteV1AppBoot extends Plugin {
|
|
4
|
-
private lastContents;
|
|
5
|
-
constructor();
|
|
6
|
-
build(): void;
|
|
7
|
-
}
|
|
8
|
-
export declare class ReadV1AppBoot extends Plugin {
|
|
9
|
-
private appBoot;
|
|
10
|
-
private hasBuilt;
|
|
11
|
-
constructor(appBootTree: Node);
|
|
12
|
-
build(): void;
|
|
13
|
-
readAppBoot(): string | undefined;
|
|
14
|
-
}
|
package/src/v1-appboot.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ReadV1AppBoot = exports.WriteV1AppBoot = void 0;
|
|
7
|
-
const broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const fs_extra_1 = require("fs-extra");
|
|
10
|
-
class WriteV1AppBoot extends broccoli_plugin_1.default {
|
|
11
|
-
constructor() {
|
|
12
|
-
super([], {
|
|
13
|
-
persistentOutput: true,
|
|
14
|
-
needsCache: false,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
build() {
|
|
18
|
-
let filename = (0, path_1.join)(this.outputPath, 'config/app-boot.js');
|
|
19
|
-
let contents = `{{content-for "app-boot"}}`;
|
|
20
|
-
if (!this.lastContents || this.lastContents !== contents) {
|
|
21
|
-
(0, fs_extra_1.outputFileSync)(filename, contents);
|
|
22
|
-
}
|
|
23
|
-
this.lastContents = contents;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.WriteV1AppBoot = WriteV1AppBoot;
|
|
27
|
-
class ReadV1AppBoot extends broccoli_plugin_1.default {
|
|
28
|
-
constructor(appBootTree) {
|
|
29
|
-
super([appBootTree], {
|
|
30
|
-
persistentOutput: true,
|
|
31
|
-
needsCache: false,
|
|
32
|
-
});
|
|
33
|
-
this.hasBuilt = false;
|
|
34
|
-
}
|
|
35
|
-
build() {
|
|
36
|
-
this.appBoot = (0, fs_extra_1.readFileSync)((0, path_1.join)(this.inputPaths[0], `config/app-boot.js`), 'utf8');
|
|
37
|
-
this.hasBuilt = true;
|
|
38
|
-
}
|
|
39
|
-
readAppBoot() {
|
|
40
|
-
if (!this.hasBuilt) {
|
|
41
|
-
throw new Error(`AppBoot not available until after the build`);
|
|
42
|
-
}
|
|
43
|
-
return this.appBoot;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.ReadV1AppBoot = ReadV1AppBoot;
|
|
47
|
-
//# sourceMappingURL=v1-appboot.js.map
|
package/src/v1-appboot.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"v1-appboot.js","sourceRoot":"","sources":["v1-appboot.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAqC;AAErC,+BAA4B;AAC5B,uCAAwD;AAExD,MAAa,cAAe,SAAQ,yBAAM;IAExC;QACE,KAAK,CAAC,EAAE,EAAE;YACR,gBAAgB,EAAE,IAAI;YACtB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;IACD,KAAK;QACH,IAAI,QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;QAC3D,IAAI,QAAQ,GAAG,4BAA4B,CAAC;QAC5C,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;YACzD,IAAA,yBAAc,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;IAC/B,CAAC;CACF;AAhBD,wCAgBC;AAED,MAAa,aAAc,SAAQ,yBAAM;IAGvC,YAAY,WAAiB;QAC3B,KAAK,CAAC,CAAC,WAAW,CAAC,EAAE;YACnB,gBAAgB,EAAE,IAAI;YACtB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QALG,aAAQ,GAAG,KAAK,CAAC;IAMzB,CAAC;IACD,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,EAAE,MAAM,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,WAAW;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AApBD,sCAoBC","sourcesContent":["import Plugin from 'broccoli-plugin';\nimport type { Node } from 'broccoli-node-api';\nimport { join } from 'path';\nimport { readFileSync, outputFileSync } from 'fs-extra';\n\nexport class WriteV1AppBoot extends Plugin {\n private lastContents: string | undefined;\n constructor() {\n super([], {\n persistentOutput: true,\n needsCache: false,\n });\n }\n build() {\n let filename = join(this.outputPath, 'config/app-boot.js');\n let contents = `{{content-for \"app-boot\"}}`;\n if (!this.lastContents || this.lastContents !== contents) {\n outputFileSync(filename, contents);\n }\n this.lastContents = contents;\n }\n}\n\nexport class ReadV1AppBoot extends Plugin {\n private appBoot: string | undefined;\n private hasBuilt = false;\n constructor(appBootTree: Node) {\n super([appBootTree], {\n persistentOutput: true,\n needsCache: false,\n });\n }\n build() {\n this.appBoot = readFileSync(join(this.inputPaths[0], `config/app-boot.js`), 'utf8');\n this.hasBuilt = true;\n }\n\n readAppBoot() {\n if (!this.hasBuilt) {\n throw new Error(`AppBoot not available until after the build`);\n }\n return this.appBoot;\n }\n}\n"]}
|