@embroider/compat 3.5.7-unstable.3b061c2 → 3.5.7
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/package.json +6 -6
- package/src/addon-dependency-rules/ember-power-select-with-create.js +1 -0
- package/src/addon-dependency-rules/ember-power-select-with-create.js.map +1 -1
- package/src/audit/babel-visitor.js +1 -7
- package/src/audit/babel-visitor.js.map +1 -1
- package/src/audit.d.ts +53 -6
- package/src/audit.js +276 -92
- package/src/audit.js.map +1 -1
- package/src/babel-plugin-adjust-imports.js +1 -1
- package/src/babel-plugin-adjust-imports.js.map +1 -1
- package/src/compat-adapters/@ember-data/debug.d.ts +6 -0
- package/src/compat-adapters/@ember-data/debug.js +22 -0
- package/src/compat-adapters/@ember-data/debug.js.map +1 -0
- package/src/compat-adapters/@ember-data/store.d.ts +5 -1
- package/src/compat-adapters/@ember-data/store.js +15 -3
- package/src/compat-adapters/@ember-data/store.js.map +1 -1
- package/src/compat-addons.js +1 -1
- package/src/compat-addons.js.map +1 -1
- package/src/compat-app-builder.d.ts +31 -9
- package/src/compat-app-builder.js +854 -122
- package/src/compat-app-builder.js.map +1 -1
- package/src/compat-app.d.ts +10 -2
- package/src/compat-app.js +73 -52
- package/src/compat-app.js.map +1 -1
- package/src/default-pipeline.d.ts +2 -2
- package/src/default-pipeline.js +0 -21
- package/src/default-pipeline.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -2
- package/src/index.js.map +1 -1
- package/src/options.d.ts +0 -3
- package/src/options.js +0 -3
- package/src/options.js.map +1 -1
- package/src/resolver-transform.js +38 -15
- package/src/resolver-transform.js.map +1 -1
- package/src/standalone-addon-build.js +4 -4
- package/src/standalone-addon-build.js.map +1 -1
- package/src/v1-appboot.d.ts +14 -0
- package/src/v1-appboot.js +47 -0
- package/src/v1-appboot.js.map +1 -0
- package/src/v1-config.d.ts +8 -0
- package/src/v1-config.js +51 -1
- package/src/v1-config.js.map +1 -1
- package/src/compat-adapters/ember-fetch.d.ts +0 -5
- package/src/compat-adapters/ember-fetch.js +0 -19
- package/src/compat-adapters/ember-fetch.js.map +0 -1
- package/src/content-for-config.d.ts +0 -11
- package/src/content-for-config.js +0 -66
- package/src/content-for-config.js.map +0 -1
- package/src/http-audit.d.ts +0 -13
- package/src/http-audit.js +0 -45
- package/src/http-audit.js.map +0 -1
- package/src/module-visitor.d.ts +0 -52
- package/src/module-visitor.js +0 -285
- package/src/module-visitor.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
package/src/v1-config.d.ts
CHANGED
|
@@ -14,3 +14,11 @@ export declare class V1Config extends Plugin {
|
|
|
14
14
|
build(): void;
|
|
15
15
|
readConfig(): ConfigContents;
|
|
16
16
|
}
|
|
17
|
+
export declare class WriteV1Config extends Plugin {
|
|
18
|
+
private inputTree;
|
|
19
|
+
private storeConfigInMeta;
|
|
20
|
+
private testInputTree?;
|
|
21
|
+
private lastContents;
|
|
22
|
+
constructor(inputTree: V1Config, storeConfigInMeta: boolean, testInputTree?: V1Config | undefined);
|
|
23
|
+
build(): void;
|
|
24
|
+
}
|
package/src/v1-config.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.V1Config = void 0;
|
|
6
|
+
exports.WriteV1Config = exports.V1Config = void 0;
|
|
7
7
|
const broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const fs_extra_1 = require("fs-extra");
|
|
@@ -23,4 +23,54 @@ class V1Config extends broccoli_plugin_1.default {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.V1Config = V1Config;
|
|
26
|
+
class WriteV1Config extends broccoli_plugin_1.default {
|
|
27
|
+
constructor(inputTree, storeConfigInMeta, testInputTree) {
|
|
28
|
+
super([inputTree, testInputTree].filter(Boolean), {
|
|
29
|
+
persistentOutput: true,
|
|
30
|
+
needsCache: false,
|
|
31
|
+
});
|
|
32
|
+
this.inputTree = inputTree;
|
|
33
|
+
this.storeConfigInMeta = storeConfigInMeta;
|
|
34
|
+
this.testInputTree = testInputTree;
|
|
35
|
+
}
|
|
36
|
+
build() {
|
|
37
|
+
let filename = (0, path_1.join)(this.outputPath, 'config/environment.js');
|
|
38
|
+
let contents;
|
|
39
|
+
if (this.storeConfigInMeta) {
|
|
40
|
+
contents = metaLoader();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
if (this.testInputTree) {
|
|
44
|
+
contents = `
|
|
45
|
+
import { isTesting } from '@embroider/macros';
|
|
46
|
+
let env;
|
|
47
|
+
if (isTesting()) {
|
|
48
|
+
env = ${JSON.stringify(this.testInputTree.readConfig())};
|
|
49
|
+
} else {
|
|
50
|
+
env = ${JSON.stringify(this.inputTree.readConfig())};
|
|
51
|
+
}
|
|
52
|
+
export default env;
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
contents = `export default ${JSON.stringify(this.inputTree.readConfig())};`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!this.lastContents || this.lastContents !== contents) {
|
|
60
|
+
(0, fs_extra_1.outputFileSync)(filename, contents);
|
|
61
|
+
}
|
|
62
|
+
this.lastContents = contents;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.WriteV1Config = WriteV1Config;
|
|
66
|
+
function metaLoader() {
|
|
67
|
+
// Supporting config content as JS Module.
|
|
68
|
+
// Wrapping the content with immediate invoked function as
|
|
69
|
+
// replaced content for config-module was meant to support AMD module.
|
|
70
|
+
return `
|
|
71
|
+
export default (function() {
|
|
72
|
+
{{content-for 'config-module'}}
|
|
73
|
+
})().default;
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
26
76
|
//# sourceMappingURL=v1-config.js.map
|
package/src/v1-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-config.js","sourceRoot":"","sources":["v1-config.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAqC;AAErC,+BAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"v1-config.js","sourceRoot":"","sources":["v1-config.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAqC;AAErC,+BAA4B;AAC5B,uCAAwD;AAUxD,MAAa,QAAS,SAAQ,yBAAM;IAElC,YAAY,UAAgB,EAAU,GAAW;QAC/C,KAAK,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;QADY,QAAG,GAAH,GAAG,CAAQ;I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CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,QAAQ,GAAG,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC;YAC9E,CAAC;QACH,CAAC;QACD,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;AAlCD,sCAkCC;AAED,SAAS,UAAU;IACjB,0CAA0C;IAC1C,0DAA0D;IAC1D,sEAAsE;IACtE,OAAO;;;;GAIN,CAAC;AACJ,CAAC","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 interface ConfigContents {\n modulePrefix: string;\n podModulePrefix?: string;\n EmberENV: unknown;\n APP: unknown;\n rootURL: string;\n}\n\nexport class V1Config extends Plugin {\n private lastConfig: ConfigContents | undefined;\n constructor(configTree: Node, private env: string) {\n super([configTree], {});\n }\n build() {\n this.lastConfig = JSON.parse(readFileSync(join(this.inputPaths[0], 'environments', `${this.env}.json`), 'utf8'));\n }\n readConfig() {\n if (!this.lastConfig) {\n throw new Error(`V1Config not available until after the build`);\n }\n return this.lastConfig;\n }\n}\n\nexport class WriteV1Config extends Plugin {\n private lastContents: string | undefined;\n constructor(private inputTree: V1Config, private storeConfigInMeta: boolean, private testInputTree?: V1Config) {\n super([inputTree, testInputTree as V1Config].filter(Boolean), {\n persistentOutput: true,\n needsCache: false,\n });\n }\n build() {\n let filename = join(this.outputPath, 'config/environment.js');\n let contents;\n if (this.storeConfigInMeta) {\n contents = metaLoader();\n } else {\n if (this.testInputTree) {\n contents = `\n import { isTesting } from '@embroider/macros';\n let env;\n if (isTesting()) {\n env = ${JSON.stringify(this.testInputTree.readConfig())};\n } else {\n env = ${JSON.stringify(this.inputTree.readConfig())};\n }\n export default env;\n `;\n } else {\n contents = `export default ${JSON.stringify(this.inputTree.readConfig())};`;\n }\n }\n if (!this.lastContents || this.lastContents !== contents) {\n outputFileSync(filename, contents);\n }\n this.lastContents = contents;\n }\n}\n\nfunction metaLoader() {\n // Supporting config content as JS Module.\n // Wrapping the content with immediate invoked function as\n // replaced content for config-module was meant to support AMD module.\n return `\n export default (function() {\n {{content-for 'config-module'}}\n })().default;\n `;\n}\n"]}
|
|
@@ -1,19 +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
|
-
class default_1 extends v1_addon_1.default {
|
|
8
|
-
get packageMeta() {
|
|
9
|
-
let meta = super.packageMeta;
|
|
10
|
-
// this file is not accessible from the outside of ember-fetch and is not being used inside ember-fetch so it's dead code
|
|
11
|
-
// but it is importing `@ember/polyfills` which casues ember-source@5 to crash because it has been removed
|
|
12
|
-
if (meta['implicit-modules']) {
|
|
13
|
-
meta['implicit-modules'] = meta['implicit-modules'].filter(mod => mod !== './utils/mung-options-for-fetch');
|
|
14
|
-
}
|
|
15
|
-
return meta;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = default_1;
|
|
19
|
-
//# sourceMappingURL=ember-fetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ember-fetch.js","sourceRoot":"","sources":["ember-fetch.ts"],"names":[],"mappings":";;;;;AAAA,2DAAkC;AAGlC,eAAqB,SAAQ,kBAAO;IAClC,IAAI,WAAW;QACb,IAAI,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;QAE7B,yHAAyH;QACzH,0GAA0G;QAC1G,IAAI,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,gCAAgC,CAAC,CAAC;QAC9G,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAZD,4BAYC","sourcesContent":["import V1Addon from '../v1-addon';\nimport type { AddonMeta } from '@embroider/core';\n\nexport default class extends V1Addon {\n get packageMeta(): Partial<AddonMeta> {\n let meta = super.packageMeta;\n\n // this file is not accessible from the outside of ember-fetch and is not being used inside ember-fetch so it's dead code\n // but it is importing `@ember/polyfills` which casues ember-source@5 to crash because it has been removed\n if (meta['implicit-modules']) {\n meta['implicit-modules'] = meta['implicit-modules'].filter(mod => mod !== './utils/mung-options-for-fetch');\n }\n\n return meta;\n }\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Plugin from 'broccoli-plugin';
|
|
2
|
-
import type { Node } from 'broccoli-node-api';
|
|
3
|
-
export default class ContentForConfig extends Plugin {
|
|
4
|
-
private options;
|
|
5
|
-
private contentFor;
|
|
6
|
-
private defaultContentForTypes;
|
|
7
|
-
constructor(configTree: Node, options: any);
|
|
8
|
-
readContents(): any;
|
|
9
|
-
build(): void;
|
|
10
|
-
getAppConfig(): any;
|
|
11
|
-
}
|
|
@@ -1,66 +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 broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
|
|
7
|
-
const fs_extra_1 = require("fs-extra");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
class ContentForConfig extends broccoli_plugin_1.default {
|
|
10
|
-
constructor(configTree, options) {
|
|
11
|
-
super([configTree], {
|
|
12
|
-
annotation: 'embroider:content-for-config',
|
|
13
|
-
persistentOutput: true,
|
|
14
|
-
needsCache: false,
|
|
15
|
-
});
|
|
16
|
-
this.options = options;
|
|
17
|
-
this.defaultContentForTypes = [
|
|
18
|
-
'head',
|
|
19
|
-
'test-head',
|
|
20
|
-
'head-footer',
|
|
21
|
-
'test-head-footer',
|
|
22
|
-
'body',
|
|
23
|
-
'test-body',
|
|
24
|
-
'body-footer',
|
|
25
|
-
'test-body-footer',
|
|
26
|
-
'config-module',
|
|
27
|
-
'app-boot',
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
readContents() {
|
|
31
|
-
if (!this.contentFor) {
|
|
32
|
-
throw new Error(`ContentForConfig not available until after the build`);
|
|
33
|
-
}
|
|
34
|
-
return this.contentFor;
|
|
35
|
-
}
|
|
36
|
-
build() {
|
|
37
|
-
var _a;
|
|
38
|
-
if (!this.contentFor)
|
|
39
|
-
this.contentFor = {};
|
|
40
|
-
const availableContentForTypes = (_a = this.options.availableContentForTypes) !== null && _a !== void 0 ? _a : [];
|
|
41
|
-
const extendedContentTypes = new Set([...this.defaultContentForTypes, ...availableContentForTypes]);
|
|
42
|
-
let appConfig = this.getAppConfig();
|
|
43
|
-
appConfig.forEach((configPath) => {
|
|
44
|
-
extendedContentTypes.forEach(contentType => {
|
|
45
|
-
const matchExp = this.options.pattern.match;
|
|
46
|
-
if (!this.contentFor[configPath.file])
|
|
47
|
-
this.contentFor[configPath.file] = {};
|
|
48
|
-
if (!this.contentFor[configPath.file][contentType]) {
|
|
49
|
-
let contents = this.options.pattern.replacement.call(null, configPath.json, matchExp, contentType);
|
|
50
|
-
this.contentFor[configPath.file][contentType] = contents;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
getAppConfig() {
|
|
56
|
-
return this.options.configPaths.map((configPath) => {
|
|
57
|
-
let config = (0, fs_extra_1.readFileSync)((0, path_1.join)(this.inputPaths[0], configPath.path), { encoding: 'utf8' });
|
|
58
|
-
return {
|
|
59
|
-
file: configPath.file,
|
|
60
|
-
json: JSON.parse(config),
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.default = ContentForConfig;
|
|
66
|
-
//# sourceMappingURL=content-for-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-for-config.js","sourceRoot":"","sources":["content-for-config.ts"],"names":[],"mappings":";;;;;AAAA,sEAAqC;AAErC,uCAAwC;AACxC,+BAA4B;AAE5B,MAAqB,gBAAiB,SAAQ,yBAAM;IAmBlD,YAAY,UAAgB,EAAU,OAAY;QAChD,KAAK,CAAC,CAAC,UAAU,CAAC,EAAE;YAClB,UAAU,EAAE,8BAA8B;YAC1C,gBAAgB,EAAE,IAAI;YACtB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QALiC,YAAO,GAAP,OAAO,CAAK;QAb1C,2BAAsB,GAAG;YAC/B,MAAM;YACN,WAAW;YACX,aAAa;YACb,kBAAkB;YAClB,MAAM;YACN,WAAW;YACX,aAAa;YACb,kBAAkB;YAClB,eAAe;YACf,UAAU;SACX,CAAC;IAQF,CAAC;IAED,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,KAAK;;QACH,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAC3C,MAAM,wBAAwB,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,wBAAwB,mCAAI,EAAE,CAAC;QAC7E,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,sBAAsB,EAAE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AC,CAAC;IACL,CAAC;CACF;AA7DD,mCA6DC","sourcesContent":["import Plugin from 'broccoli-plugin';\nimport type { Node } from 'broccoli-node-api';\nimport { readFileSync } from 'fs-extra';\nimport { join } from 'path';\n\nexport default class ContentForConfig extends Plugin {\n // The object keys are the content types and each value is the HTML\n // code that should replace the corresponding {{content-for}}\n // Example: { body: '<p>This snippet replaces content-for \\\"body\\\" in the app index.html</p>' }\n private contentFor: any;\n\n private defaultContentForTypes = [\n 'head',\n 'test-head',\n 'head-footer',\n 'test-head-footer',\n 'body',\n 'test-body',\n 'body-footer',\n 'test-body-footer',\n 'config-module',\n 'app-boot',\n ];\n\n constructor(configTree: Node, private options: any) {\n super([configTree], {\n annotation: 'embroider:content-for-config',\n persistentOutput: true,\n needsCache: false,\n });\n }\n\n readContents() {\n if (!this.contentFor) {\n throw new Error(`ContentForConfig not available until after the build`);\n }\n return this.contentFor;\n }\n\n build() {\n if (!this.contentFor) this.contentFor = {};\n const availableContentForTypes = this.options.availableContentForTypes ?? [];\n const extendedContentTypes = new Set([...this.defaultContentForTypes, ...availableContentForTypes]);\n\n let appConfig = this.getAppConfig();\n appConfig.forEach((configPath: { file: string; json: any }) => {\n extendedContentTypes.forEach(contentType => {\n const matchExp = this.options.pattern.match;\n if (!this.contentFor[configPath.file]) this.contentFor[configPath.file] = {};\n if (!this.contentFor[configPath.file][contentType]) {\n let contents = this.options.pattern.replacement.call(null, configPath.json, matchExp, contentType);\n this.contentFor[configPath.file][contentType] = contents;\n }\n });\n });\n }\n\n getAppConfig() {\n return this.options.configPaths.map((configPath: { file: string; path: string }) => {\n let config = readFileSync(join(this.inputPaths[0], configPath.path), { encoding: 'utf8' });\n return {\n file: configPath.file,\n json: JSON.parse(config),\n };\n });\n }\n}\n"]}
|
package/src/http-audit.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Finding } from './audit';
|
|
2
|
-
import { type Module } from './module-visitor';
|
|
3
|
-
export interface HTTPAuditOptions {
|
|
4
|
-
appURL: string;
|
|
5
|
-
startingFrom: string[];
|
|
6
|
-
fetch?: typeof fetch;
|
|
7
|
-
}
|
|
8
|
-
export declare function httpAudit(options: HTTPAuditOptions): Promise<{
|
|
9
|
-
modules: {
|
|
10
|
-
[file: string]: Module;
|
|
11
|
-
};
|
|
12
|
-
findings: Finding[];
|
|
13
|
-
}>;
|
package/src/http-audit.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.httpAudit = httpAudit;
|
|
4
|
-
const babel_visitor_1 = require("./audit/babel-visitor");
|
|
5
|
-
const module_visitor_1 = require("./module-visitor");
|
|
6
|
-
async function httpAudit(options) {
|
|
7
|
-
let findings = [];
|
|
8
|
-
async function resolveId(specifier, fromFile) {
|
|
9
|
-
return new URL(specifier, fromFile).href;
|
|
10
|
-
}
|
|
11
|
-
async function load(id) {
|
|
12
|
-
var _a;
|
|
13
|
-
let response = await ((_a = options.fetch) !== null && _a !== void 0 ? _a : globalThis.fetch)(id);
|
|
14
|
-
let content = await response.text();
|
|
15
|
-
let type;
|
|
16
|
-
if (response.status !== 200) {
|
|
17
|
-
throw new Error(`oops status code ${response.status} - ${response.statusText} for ${id}: ${content}`);
|
|
18
|
-
}
|
|
19
|
-
switch (response.headers.get('content-type')) {
|
|
20
|
-
case 'text/javascript':
|
|
21
|
-
type = 'javascript';
|
|
22
|
-
break;
|
|
23
|
-
case 'text/html':
|
|
24
|
-
type = 'html';
|
|
25
|
-
break;
|
|
26
|
-
default:
|
|
27
|
-
throw new Error(`oops content type ${response.headers.get('content-type')} for ${id}`);
|
|
28
|
-
}
|
|
29
|
-
return { content, type };
|
|
30
|
-
}
|
|
31
|
-
let modules = await (0, module_visitor_1.visitModules)({
|
|
32
|
-
base: options.appURL,
|
|
33
|
-
entrypoints: options.startingFrom.map(s => new URL(s, options.appURL).href),
|
|
34
|
-
babelConfig: { ast: true },
|
|
35
|
-
frames: new babel_visitor_1.CodeFrameStorage(),
|
|
36
|
-
findings,
|
|
37
|
-
resolveId,
|
|
38
|
-
load,
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
modules,
|
|
42
|
-
findings,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=http-audit.js.map
|
package/src/http-audit.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-audit.js","sourceRoot":"","sources":["http-audit.ts"],"names":[],"mappings":";;AAUA,8BA2CC;AApDD,yDAAyD;AACzD,qDAA+E;AAQxE,KAAK,UAAU,SAAS,CAC7B,OAAyB;IAEzB,IAAI,QAAQ,GAAc,EAAE,CAAC;IAE7B,KAAK,UAAU,SAAS,CAAC,SAAiB,EAAE,QAAgB;QAC1D,OAAO,IAAI,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC;IAC3C,CAAC;IAED,KAAK,UAAU,IAAI,CAAC,EAAU;;QAC5B,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAA,OAAO,CAAC,KAAK,mCAAI,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QAC7D,IAAI,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,IAAiB,CAAC;QACtB,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,UAAU,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC,CAAC;QACxG,CAAC;QACD,QAAQ,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;YAC7C,KAAK,iBAAiB;gBACpB,IAAI,GAAG,YAAY,CAAC;gBACpB,MAAM;YACR,KAAK,WAAW;gBACd,IAAI,GAAG,MAAM,CAAC;gBACd,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO,GAAG,MAAM,IAAA,6BAAY,EAAC;QAC/B,IAAI,EAAE,OAAO,CAAC,MAAM;QACpB,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;QAC3E,WAAW,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;QAC1B,MAAM,EAAE,IAAI,gCAAgB,EAAE;QAC9B,QAAQ;QACR,SAAS;QACT,IAAI;KACL,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC","sourcesContent":["import type { Finding } from './audit';\nimport { CodeFrameStorage } from './audit/babel-visitor';\nimport { type Module, visitModules, type ContentType } from './module-visitor';\n\nexport interface HTTPAuditOptions {\n appURL: string;\n startingFrom: string[];\n fetch?: typeof fetch;\n}\n\nexport async function httpAudit(\n options: HTTPAuditOptions\n): Promise<{ modules: { [file: string]: Module }; findings: Finding[] }> {\n let findings: Finding[] = [];\n\n async function resolveId(specifier: string, fromFile: string): Promise<string | undefined> {\n return new URL(specifier, fromFile).href;\n }\n\n async function load(id: string): Promise<{ content: string | Buffer; type: ContentType }> {\n let response = await (options.fetch ?? globalThis.fetch)(id);\n let content = await response.text();\n let type: ContentType;\n if (response.status !== 200) {\n throw new Error(`oops status code ${response.status} - ${response.statusText} for ${id}: ${content}`);\n }\n switch (response.headers.get('content-type')) {\n case 'text/javascript':\n type = 'javascript';\n break;\n case 'text/html':\n type = 'html';\n break;\n default:\n throw new Error(`oops content type ${response.headers.get('content-type')} for ${id}`);\n }\n return { content, type };\n }\n\n let modules = await visitModules({\n base: options.appURL,\n entrypoints: options.startingFrom.map(s => new URL(s, options.appURL).href),\n babelConfig: { ast: true },\n frames: new CodeFrameStorage(),\n findings,\n resolveId,\n load,\n });\n\n return {\n modules,\n findings,\n };\n}\n"]}
|
package/src/module-visitor.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { type CodeFrameStorage, type NamespaceMarker } from './audit/babel-visitor';
|
|
2
|
-
import type { Finding } from './audit';
|
|
3
|
-
import type { TransformOptions } from '@babel/core';
|
|
4
|
-
export type Module = CompleteModule | ParsedModule | UnparseableModule;
|
|
5
|
-
export interface UnparseableModule {
|
|
6
|
-
type: 'unparseable';
|
|
7
|
-
appRelativePath: string;
|
|
8
|
-
consumedFrom: (string | RootMarker)[];
|
|
9
|
-
}
|
|
10
|
-
export interface ParsedModule extends Omit<UnparseableModule, 'type'> {
|
|
11
|
-
type: 'parsed';
|
|
12
|
-
imports: Import[];
|
|
13
|
-
resolutions: {
|
|
14
|
-
[source: string]: string | null;
|
|
15
|
-
};
|
|
16
|
-
content: string;
|
|
17
|
-
isCJS: boolean;
|
|
18
|
-
isAMD: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface CompleteModule extends Omit<ParsedModule, 'type'> {
|
|
21
|
-
type: 'complete';
|
|
22
|
-
exports: string[];
|
|
23
|
-
}
|
|
24
|
-
export interface Import {
|
|
25
|
-
source: string;
|
|
26
|
-
specifiers: {
|
|
27
|
-
name: string | NamespaceMarker;
|
|
28
|
-
local: string | null;
|
|
29
|
-
codeFrameIndex: number | undefined;
|
|
30
|
-
}[];
|
|
31
|
-
codeFrameIndex: number | undefined;
|
|
32
|
-
}
|
|
33
|
-
interface VisitorParams {
|
|
34
|
-
base: string;
|
|
35
|
-
resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;
|
|
36
|
-
load: (id: string) => Promise<{
|
|
37
|
-
content: string | Buffer;
|
|
38
|
-
type: ContentType;
|
|
39
|
-
} | undefined>;
|
|
40
|
-
entrypoints: string[];
|
|
41
|
-
debug?: boolean;
|
|
42
|
-
findings: Finding[];
|
|
43
|
-
frames: CodeFrameStorage;
|
|
44
|
-
babelConfig: TransformOptions;
|
|
45
|
-
}
|
|
46
|
-
export declare function visitModules(params: VisitorParams): Promise<Record<string, Module>>;
|
|
47
|
-
export type ContentType = 'javascript' | 'html';
|
|
48
|
-
export interface RootMarker {
|
|
49
|
-
isRoot: true;
|
|
50
|
-
}
|
|
51
|
-
export declare function isRootMarker(value: string | RootMarker | undefined): value is RootMarker;
|
|
52
|
-
export {};
|