Skip to content

Commit ea6aa48

Browse files
committed
Force people using the default blueprint to move to the newly published package
1 parent 758510a commit ea6aa48

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

src/constants.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ module.exports.defaultAddonBlueprintName = 'addon';
77
module.exports.glimmerPackageName = '@glimmer/blueprint';
88

99
module.exports.defaultTo = '*';
10+
11+
module.exports.EMBER_LEGACY_BLUEPRINT_VERSION = '6.7.0';
12+
module.exports.CLASSIC_BUILD_APP_BLUEPRINT =
13+
'@ember-tooling/classic-build-app-blueprint';

src/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@ const getBaseBlueprint = require('./get-base-blueprint');
2020
const chooseBlueprintUpdates = require('./choose-blueprint-updates');
2121
const getBlueprintFilePath = require('./get-blueprint-file-path');
2222
const resolvePackage = require('./resolve-package');
23-
const { defaultTo } = require('./constants');
23+
const {
24+
defaultTo,
25+
defaultAppBlueprintName,
26+
defaultPackageName,
27+
EMBER_LEGACY_BLUEPRINT_VERSION,
28+
CLASSIC_BUILD_APP_BLUEPRINT
29+
} = require('./constants');
2430
const normalizeBlueprintArgs = require('./normalize-blueprint-args');
31+
const semver = require('semver');
2532

2633
/**
2734
* If `version` attribute exists in the `blueprint` object and URL is empty, skip. Otherwise resolve the details of
@@ -211,6 +218,18 @@ module.exports = async function emberCliUpdate({
211218
let versions = await getVersions(packageName);
212219
let getTagVersion = _getTagVersion(versions, packageName);
213220
endBlueprint.version = await getTagVersion(to);
221+
222+
if (
223+
endBlueprint.isBaseBlueprint &&
224+
packageName === defaultPackageName &&
225+
endBlueprint.name === defaultAppBlueprintName &&
226+
semver.gte(to, EMBER_LEGACY_BLUEPRINT_VERSION)
227+
) {
228+
endBlueprint.name = CLASSIC_BUILD_APP_BLUEPRINT;
229+
endBlueprint.packageName = CLASSIC_BUILD_APP_BLUEPRINT;
230+
231+
await _resolvePackage(endBlueprint, packageUrl, to);
232+
}
214233
}
215234

216235
let customDiffOptions = getStartAndEndCommands({

src/save-blueprint.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
const utils = require('./utils');
44
const findBlueprint = require('./find-blueprint');
5+
const {
6+
defaultPackageName,
7+
defaultAppBlueprintName,
8+
EMBER_LEGACY_BLUEPRINT_VERSION,
9+
CLASSIC_BUILD_APP_BLUEPRINT
10+
} = require('./constants');
11+
const semver = require('semver');
512

613
function addBlueprint(emberCliUpdateJson, blueprint) {
714
emberCliUpdateJson.blueprints.push(blueprint);
@@ -67,6 +74,19 @@ async function saveBlueprint({ emberCliUpdateJsonPath, blueprint }) {
6774
savedBlueprint.version = version;
6875
}
6976

77+
if (
78+
savedBlueprint.isBaseBlueprint &&
79+
packageName === defaultPackageName &&
80+
name === defaultAppBlueprintName &&
81+
semver.gte(version, EMBER_LEGACY_BLUEPRINT_VERSION)
82+
) {
83+
savedBlueprint.name = CLASSIC_BUILD_APP_BLUEPRINT;
84+
delete savedBlueprint.packageName;
85+
delete savedBlueprint.location;
86+
delete savedBlueprint.codemodsSource;
87+
delete savedBlueprint.outputRepo;
88+
}
89+
7090
await utils.saveBlueprintFile(emberCliUpdateJsonPath, emberCliUpdateJson);
7191
}
7292

0 commit comments

Comments
 (0)