Skip to content

Commit

Permalink
continue to support auto-upgraded dummy apps
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Aug 9, 2024
1 parent dee0c76 commit 9892ac6
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions packages/compat/src/compat-app-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,20 +470,7 @@ export class CompatAppBuilder {
assetPaths.push('package.json');
}

let meta: AppMeta = {
type: 'app',
version: 2,
assets: assetPaths,
babel: {
filename: '_babel_config_.js',
isParallelSafe: true, // TODO
majorVersion: this.compatApp.babelMajorVersion(),
fileFilter: '_babel_filter_.js',
},
'root-url': this.rootURL(),
};

let pkg = this.combinePackageJSON(meta);
let pkg = this.combinePackageJSON(assetPaths);
writeFileSync(join(this.root, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');

let resolverConfig = this.resolverConfig(appFiles);
Expand All @@ -499,15 +486,31 @@ export class CompatAppBuilder {
this.addMacrosConfig(this.compatApp.macrosConfig.babelPluginConfig()[0]);
}

private combinePackageJSON(meta: AppMeta): object {
private combinePackageJSON(assetPaths: string[]): object {
let pkgLayers: any[] = [this.origAppPackage.packageJSON];
let fastbootConfig = this.fastbootConfig;
if (fastbootConfig) {
// fastboot-specific package.json output is allowed to add to our original package.json
pkgLayers.push(fastbootConfig.packageJSON);
}
// but our own new v2 app metadata takes precedence over both
pkgLayers.push({ 'ember-addon': meta });

if ((this.origAppPackage.packageJSON['ember-addon']?.version ?? 0) < 2) {
// the app has no v2 metdata, so we must be auto-upgrading it
let meta: AppMeta = {
type: 'app',
version: 2,
assets: assetPaths,
babel: {
filename: '_babel_config_.js',
isParallelSafe: true, // TODO
majorVersion: this.compatApp.babelMajorVersion(),
fileFilter: '_babel_filter_.js',
},
'root-url': this.rootURL(),
'auto-upgraded': true,
};
pkgLayers.push({ 'ember-addon': meta });
}
return combinePackageJSON(...pkgLayers);
}

Expand Down

0 comments on commit 9892ac6

Please sign in to comment.