-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.js
More file actions
92 lines (75 loc) · 2.28 KB
/
index.js
File metadata and controls
92 lines (75 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'use strict';
let date = new Date();
const description = 'The default blueprint for Embroider v2 addons.';
module.exports = {
name: "face",
description,
fileMapTokens(options) {
let { ext } = options.locals;
return {
__ext__: () => ext,
};
},
locals(options) {
if (isYarn(options)) {
throw new Error(
`Please do not generate this project with --yarn. Omit '--yarn' when generating this blueprint'`,
);
}
return {
name: options.name,
blueprintVersion: require('./package.json').version,
year: date.getFullYear(),
packageManager: options.packageManager,
yarn: false,
pnpm: isPnpm(options),
npm: isNpm(options),
typescript: options.typescript,
ext: options.typescript ? 'ts' : 'js',
blueprint: 'addon',
blueprintOptions: buildBlueprintOptions({
[`--ci-provider=${options.ciProvider}`]: options.ciProvider,
'--pnpm': isPnpm(options),
'--npm': isNpm(options),
'--typescript': options.typescript,
}),
ciProvider: options.ciProvider,
};
},
files(options) {
let files = this._super.files.apply(this, arguments);
if (!options.typescript) {
let ignoredFiles = ['tsconfig.json'];
files = files.filter(
(filename) => !filename.match(/.*\.ts$/) && !ignoredFiles.includes(filename),
);
}
return files;
},
};
function buildBlueprintOptions(blueprintOptions) {
let blueprintOptionsFiltered = Object.keys(blueprintOptions).filter((option) => {
return Boolean(blueprintOptions[option]);
});
if (blueprintOptionsFiltered.length > 0) {
return (
`\n ` +
blueprintOptionsFiltered.map((option) => `"${option}"`).join(',\n ') +
`\n `
);
}
return '';
}
// These methods exist because in ember-cli 5.4, package manager handling
// had changed to solely use the packageManager key, however
// prior to ember-cli 5.4, pnpm, yarn, and npm, had their own booleans on
// the options object.
function isPnpm(options) {
return options.packageManager === 'pnpm' || options.pnpm;
}
function isYarn(options) {
return options.packageManager === 'yarn' || options.yarn;
}
function isNpm(options) {
return options.packageManager === 'npm' || options.npm;
}