Skip to content

Commit 8e3a365

Browse files
committed
Cleanup
1 parent 100a823 commit 8e3a365

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

src/index.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,21 @@ const resolvePackage = require('./resolve-package');
2323
const { defaultTo } = require('./constants');
2424
const normalizeBlueprintArgs = require('./normalize-blueprint-args');
2525

26+
/**
27+
* @typedef {Object} Blueprint
28+
* @property {string} name
29+
* @property {string[]} options - args passed to the blueprint
30+
* @property {string} packageName - The name of the package containing the blueprint
31+
* @property {string} location
32+
* @property {string} version
33+
* @property {boolean} isBaseBlueprint
34+
*/
35+
2636
/**
2737
* If `version` attribute exists in the `blueprint` object and URL is empty, skip. Otherwise resolve the details of
2838
* the blueprint
2939
*
30-
* @param {Object} blueprint - Expected to contain `name`, `options` array, `packageName`, `location`, and `version`
40+
* @param {Blueprint} blueprint - Expected to contain `name`, `options` array, `packageName`, `location`, and `version`
3141
* attributes
3242
* @param {String} url - Optional parameter that links to package
3343
* @param {String} range - Version range i.e. 1.0.2
@@ -64,11 +74,11 @@ module.exports = async function emberCliUpdate({
6474
// so we can no longer look it up on the fly after the run.
6575
// We must rely on a lookup before the run.
6676
let emberCliUpdateJsonPath = await getBlueprintFilePath(cwd);
67-
6877
let emberCliUpdateJson = await loadSafeBlueprintFile(emberCliUpdateJsonPath);
6978

7079
let { blueprints } = emberCliUpdateJson;
7180

81+
/** @type {Blueprint} */
7282
let blueprint;
7383
let packageUrl;
7484

@@ -77,14 +87,14 @@ module.exports = async function emberCliUpdate({
7787
packageName,
7888
blueprintName: _blueprint
7989
});
80-
8190
let parsedPackage = await parseBlueprintPackage({
8291
cwd,
8392
packageName: blueprintArgs.packageName
8493
});
85-
packageUrl = parsedPackage.url;
8694

95+
packageUrl = parsedPackage.url;
8796
packageName = parsedPackage.name;
97+
8898
if (!packageName) {
8999
let downloadedPackage = await downloadPackage(
90100
null,
@@ -190,15 +200,16 @@ module.exports = async function emberCliUpdate({
190200
);
191201
}
192202

193-
let endBlueprint;
203+
/** @type {Blueprint} */
204+
let startBlueprint = { ...blueprint };
205+
/** @type {Blueprint} */
206+
let endBlueprint = { ...blueprint };
194207

195208
let { promise, resolveConflictsProcess } = await boilerplateUpdate({
196209
cwd,
197210
projectOptions: ({ packageJson }) =>
198211
getProjectOptions(packageJson, blueprint),
199212
mergeOptions: async function mergeOptions({ packageJson, projectOptions }) {
200-
let startBlueprint = { ...blueprint };
201-
endBlueprint = { ...blueprint };
202213
delete endBlueprint.version;
203214

204215
if (isCustomBlueprint) {
@@ -207,6 +218,7 @@ module.exports = async function emberCliUpdate({
207218
_resolvePackage(endBlueprint, packageUrl, to)
208219
]);
209220
} else {
221+
startBlueprint = { ...blueprint };
210222
let packageName = getPackageName(projectOptions);
211223
let versions = await getVersions(packageName);
212224
let getTagVersion = _getTagVersion(versions, packageName);

0 commit comments

Comments
 (0)