From 1aed0c3f33a358a75b7aea83fa317e453b03b7e8 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Fri, 3 Jan 2025 13:35:27 -0500 Subject: [PATCH] Remove app meta --- packages/addon-shim/src/index.ts | 2 +- packages/compat/package.json | 7 +- packages/compat/src/audit-cli.ts | 173 ------------------ packages/compat/src/audit.ts | 28 +-- packages/compat/src/audit/options.ts | 3 +- .../src/compat-adapters/ember-cli-fastboot.ts | 1 - .../src/compat-adapters/ember-cli-mirage.ts | 1 - packages/compat/src/compat-app.ts | 2 - packages/compat/tests/audit.test.ts | 15 +- packages/core/src/index.ts | 9 +- packages/core/src/module-resolver.ts | 10 +- packages/core/src/packager.ts | 10 - packages/core/tests/packager.test.ts | 44 ----- packages/shared-internals/src/colocation.ts | 2 +- packages/shared-internals/src/index.ts | 4 +- packages/shared-internals/src/metadata.ts | 15 -- packages/shared-internals/src/package.ts | 53 ++---- .../src/rewritten-package-cache.ts | 8 +- .../tests/template-colocation-plugin.test.ts | 7 - packages/webpack/src/ember-webpack.ts | 7 +- pnpm-lock.yaml | 6 - tests/scenarios/compat-resolver-test.ts | 10 - tests/scenarios/core-resolver-test.ts | 20 +- 23 files changed, 54 insertions(+), 383 deletions(-) delete mode 100644 packages/compat/src/audit-cli.ts delete mode 100644 packages/core/tests/packager.test.ts diff --git a/packages/addon-shim/src/index.ts b/packages/addon-shim/src/index.ts index 340e4814a..5a76b5d64 100644 --- a/packages/addon-shim/src/index.ts +++ b/packages/addon-shim/src/index.ts @@ -26,7 +26,7 @@ export interface ShimOptions { function addonMeta(pkgJSON: PackageInfo): AddonMeta { let meta = pkgJSON['ember-addon']; - if (meta?.version !== 2 || meta?.type !== 'addon') { + if (meta?.version !== 2) { throw new Error(`did not find valid v2 addon metadata in ${pkgJSON.name}`); } return meta as AddonMeta; diff --git a/packages/compat/package.json b/packages/compat/package.json index 2163cb830..d01d8d290 100644 --- a/packages/compat/package.json +++ b/packages/compat/package.json @@ -17,9 +17,6 @@ "src/**/*.d.ts", "src/**/*.js.map" ], - "bin": { - "embroider-compat-audit": "./src/audit-cli.js" - }, "scripts": { "test": "jest" }, @@ -35,7 +32,6 @@ "@babel/traverse": "^7.14.5", "@embroider/macros": "workspace:*", "@types/babel__code-frame": "^7.0.2", - "@types/yargs": "^17.0.3", "assert-never": "^1.1.0", "babel-import-util": "^2.0.0", "babel-plugin-debug-macros": "^1.0.2", @@ -67,8 +63,7 @@ "symlink-or-copy": "^1.3.1", "tree-sync": "^2.1.0", "typescript-memoize": "^1.0.1", - "walk-sync": "^3.0.0", - "yargs": "^17.0.1" + "walk-sync": "^3.0.0" }, "devDependencies": { "@embroider/core": "workspace:^", diff --git a/packages/compat/src/audit-cli.ts b/packages/compat/src/audit-cli.ts deleted file mode 100644 index e6ac9a8c4..000000000 --- a/packages/compat/src/audit-cli.ts +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/env node - -import { readFileSync, readJSONSync, writeFileSync } from 'fs-extra'; -import { resolve } from 'path'; -import yargs from 'yargs/yargs'; -import type { Finding } from './audit'; -import { Audit, AuditResults, isBuildError } from './audit'; - -// slightly wacky because yargs types don't cover this, but you can't access the -// other documented place to find `hideBin` on node < 12.17 -const { hideBin } = yargs as any as { - hideBin(argv: readonly string[]): readonly string[]; -}; - -function runCLI() { - return yargs(hideBin(process.argv)) - .command( - '$0', - 'audit your app for embroider compatibility problems', - yargs => { - return yargs - .option('debug', { - alias: 'd', - type: 'boolean', - description: 'Add debug logging about the audit itself', - default: false, - }) - .option('json', { - alias: 'j', - type: 'boolean', - description: 'Print results in JSON format', - default: false, - }) - .option('reuse-build', { - alias: 'r', - type: 'boolean', - description: 'Reuse previous build', - default: false, - }) - .option('load', { - alias: 'l', - type: 'string', - description: 'Load previous audit results from a JSON file instead of running a new audit', - }) - .option('save', { - alias: 's', - type: 'string', - description: 'Save audit results as a JSON file.', - }) - .option('app', { - type: 'string', - description: 'Path to your app', - default: process.cwd(), - }) - .option('filter', { - type: 'string', - description: - 'Path to a JS file that describes which findings to silence. Generate the initial file using `--create-filter`.', - }) - .option('create-filter', { - type: 'string', - description: - 'Path to a JS file where we will create a filter that will silence all your current findings. Pass it back into future audits via --filter', - }) - .fail(function (_, err, _yargs) { - if (isBuildError(err)) { - process.stderr.write(err.message + '\n'); - } else { - console.error(err); - } - process.exit(1); - }); - }, - async options => { - let filter = loadFilter(options); - let results: AuditResults; - if (options.load) { - results = new AuditResults(); - Object.assign(results, readJSONSync(options.load)); - } else { - results = await Audit.run(options); - } - if (options.save) { - writeFileSync(options.save, JSON.stringify(results, null, 2)); - } - applyFilter(filter, results); - if (options.json) { - process.stdout.write(JSON.stringify(results, null, 2) + '\n'); - } else { - process.stdout.write(results.humanReadable()); - } - if (options['create-filter']) { - createFilter(options['create-filter'], results); - } - process.exit(results.perfect ? 0 : 1); - } - ) - .command( - 'pretty', - 'format JSON audit results as pretty human-readable results', - yargs => { - return yargs.option('filter', { - type: 'string', - description: - 'Path to a JS file that describes which findings to silence. Generate the file using `embroider-compat-audit acknowledge`', - }); - }, - async options => { - let filter = loadFilter(options); - let results = new AuditResults(); - // process.stdin.fd is a documented public API. The Node typings don't - // seem to know about it. - Object.assign(results, JSON.parse(readFileSync((process.stdin as any).fd, 'utf8'))); - applyFilter(filter, results); - process.stdout.write(results.humanReadable()); - process.exit(0); - } - ) - .command( - 'acknowledge', - 'Pipe your audit JSON to this command to generate a filter file that will silence the current issues. Pass the filter file into your next audit via --filter. Delete findings out of the filter file as you address them.', - yargs => yargs, - async () => { - let results = new AuditResults(); - // process.stdin.fd is a documented public API. The Node typings don't - // seem to know about it. - Object.assign(results, JSON.parse(readFileSync((process.stdin as any).fd, 'utf8'))); - let findings = results.findings.map(f => ({ - filename: f.filename, - message: f.message, - detail: f.detail, - })); - process.stdout.write(`module.exports = ${JSON.stringify({ findings }, null, 2)};\n`); - process.exit(0); - } - ).argv; -} - -if (require.main === module) { - runCLI(); -} - -type Filter = { findings: Omit[] }; - -function loadFilter(options: { filter: string | undefined }): Filter | undefined { - if (options.filter) { - // eslint-disable-next-line @typescript-eslint/no-require-imports - return require(resolve(options.filter)); - } -} - -function applyFilter(filter: Filter | undefined, results: AuditResults) { - if (filter) { - results.findings = results.findings.filter(finding => { - return !filter!.findings.find(filtered => { - return ( - filtered.message === finding.message && - filtered.detail === finding.detail && - filtered.filename === finding.filename - ); - }); - }); - } -} - -function createFilter(filename: string, results: AuditResults) { - let findings = results.findings.map(f => ({ - filename: f.filename, - message: f.message, - detail: f.detail, - })); - writeFileSync(filename, `module.exports = ${JSON.stringify({ findings }, null, 2)};\n`); -} diff --git a/packages/compat/src/audit.ts b/packages/compat/src/audit.ts index a26d4c8cc..f7b93d96f 100644 --- a/packages/compat/src/audit.ts +++ b/packages/compat/src/audit.ts @@ -1,6 +1,6 @@ import { readFileSync, readJSONSync } from 'fs-extra'; import { join, resolve as resolvePath, dirname } from 'path'; -import type { AppMeta, ResolverOptions } from '@embroider/core'; +import type { ResolverOptions } from '@embroider/core'; import { explicitRelative, hbsToJS, locateEmbroiderWorkingDir, Resolver, RewrittenPackageCache } from '@embroider/core'; import { Memoize } from 'typescript-memoize'; import chalk from 'chalk'; @@ -125,12 +125,7 @@ export class Audit { return audit.run(); } - constructor(private originAppRoot: string, private options: AuditOptions = {}) {} - - @Memoize() - private get pkg() { - return readJSONSync(join(this.movedAppRoot, 'package.json')); - } + constructor(private originAppRoot: string, private options: AuditOptions) {} @Memoize() private get movedAppRoot() { @@ -138,10 +133,6 @@ export class Audit { return cache.maybeMoved(cache.get(this.originAppRoot)).root; } - private get meta() { - return this.pkg['ember-addon'] as AppMeta; - } - @Memoize() private get babelConfig() { let origCwd = process.cwd(); @@ -166,18 +157,13 @@ export class Audit { private resolver = new Resolver(this.resolverParams); - private debug(message: string, ...args: any[]) { - if (this.options.debug) { - console.log(message, ...args); - } - } - async run(): Promise { (globalThis as any).embroider_audit = this.handleResolverError.bind(this); try { - this.debug(`meta`, this.meta); - let entrypoints = this.meta.assets.filter(a => a.endsWith('html')).map(a => resolvePath(this.movedAppRoot, a)); + let entrypoints = this.options.entrypoints + .filter(a => a.endsWith('html')) + .map(a => resolvePath(this.movedAppRoot, a)); let modules = await visitModules({ base: this.originAppRoot, @@ -204,11 +190,11 @@ export class Audit { return undefined; } - if (fromFile.endsWith('.html') && specifier.startsWith(this.meta['root-url'])) { + if (fromFile.endsWith('.html') && specifier.startsWith(this.options.rootURL)) { // root-relative URLs in HTML are actually relative to the appDir specifier = explicitRelative( dirname(fromFile), - resolvePath(this.movedAppRoot, specifier.replace(this.meta['root-url'], '')) + resolvePath(this.movedAppRoot, specifier.replace(this.options.rootURL, '')) ); } diff --git a/packages/compat/src/audit/options.ts b/packages/compat/src/audit/options.ts index f84cf9d57..19d4c7d6b 100644 --- a/packages/compat/src/audit/options.ts +++ b/packages/compat/src/audit/options.ts @@ -1,5 +1,6 @@ export interface AuditOptions { - debug?: boolean; + entrypoints: string[]; + rootURL: string; } export interface AuditBuildOptions extends AuditOptions { diff --git a/packages/compat/src/compat-adapters/ember-cli-fastboot.ts b/packages/compat/src/compat-adapters/ember-cli-fastboot.ts index 328599290..f7e8a7726 100644 --- a/packages/compat/src/compat-adapters/ember-cli-fastboot.ts +++ b/packages/compat/src/compat-adapters/ember-cli-fastboot.ts @@ -147,7 +147,6 @@ class RewriteManifest extends Plugin { // treated as ember code it needs to have v2 addon metadata json.keywords = [...(json.keywords ?? []), 'ember-addon']; let meta: AddonMeta = { - type: 'addon', version: 2, 'auto-upgraded': true, }; diff --git a/packages/compat/src/compat-adapters/ember-cli-mirage.ts b/packages/compat/src/compat-adapters/ember-cli-mirage.ts index 1e98a69bc..567059619 100644 --- a/packages/compat/src/compat-adapters/ember-cli-mirage.ts +++ b/packages/compat/src/compat-adapters/ember-cli-mirage.ts @@ -8,7 +8,6 @@ export default class extends V1Addon { return super.packageMeta; } return { - type: 'addon', version: 2, 'auto-upgraded': true, }; diff --git a/packages/compat/src/compat-app.ts b/packages/compat/src/compat-app.ts index 4102c8b19..12c1157e1 100644 --- a/packages/compat/src/compat-app.ts +++ b/packages/compat/src/compat-app.ts @@ -408,7 +408,6 @@ export default class CompatApp { let remapAsset = this.remapAsset.bind(this); let addonMeta: AddonMeta = { - type: 'addon', version: 2, 'implicit-scripts': this._implicitScripts.map(remapAsset).filter(forbiddenVendorPath), 'implicit-styles': this._implicitStyles.map(remapAsset), @@ -469,7 +468,6 @@ export default class CompatApp { return new AddToTree(styles, outputPath => { let addonMeta: AddonMeta = { - type: 'addon', version: 2, 'public-assets': {}, }; diff --git a/packages/compat/tests/audit.test.ts b/packages/compat/tests/audit.test.ts index 04a6e6e45..afc1474ed 100644 --- a/packages/compat/tests/audit.test.ts +++ b/packages/compat/tests/audit.test.ts @@ -1,6 +1,5 @@ import { emberTemplateCompiler } from '@embroider/test-support'; import { Project } from 'scenario-tester'; -import type { AppMeta } from '@embroider/core'; import { throwOnWarnings } from '@embroider/core'; import merge from 'lodash/merge'; import fromPairs from 'lodash/fromPairs'; @@ -22,7 +21,10 @@ describe('audit', function () { let origCwd = process.cwd(); try { process.chdir(app.baseDir); - let audit = new Audit(app.baseDir); + let audit = new Audit(app.baseDir, { + entrypoints: ['index.html'], + rootURL: '/', + }); return await audit.run(); } finally { process.chdir(origCwd); @@ -124,16 +126,7 @@ describe('audit', function () { }, }, }); - let appMeta: AppMeta = { - type: 'app', - version: 2, - assets: ['index.html'], - 'root-url': '/', - 'auto-upgraded': true, - }; merge(app.pkg, { - 'ember-addon': appMeta, - keywords: ['ember-addon'], exports: { './*': './*', './tests/*': './tests/*', diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 05ae3099b..9535ff44a 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,11 +1,4 @@ -export { - Packager, - PackagerConstructor, - Variant, - applyVariantToBabelConfig, - getAppMeta, - getPackagerCacheDir, -} from './packager'; +export { Packager, PackagerConstructor, Variant, applyVariantToBabelConfig, getPackagerCacheDir } from './packager'; export { HTMLEntrypoint, BundleSummary } from './html-entrypoint'; export { default as Stage } from './stage'; export { default as Options, optionsWithDefaults } from './options'; diff --git a/packages/core/src/module-resolver.ts b/packages/core/src/module-resolver.ts index 218abedff..b0e7609a1 100644 --- a/packages/core/src/module-resolver.ts +++ b/packages/core/src/module-resolver.ts @@ -9,7 +9,7 @@ import { syntheticJStoHBS, } from '@embroider/shared-internals'; import { dirname, resolve, posix, basename } from 'path'; -import type { Package, V2Package } from '@embroider/shared-internals'; +import type { Package } from '@embroider/shared-internals'; import { explicitRelative, RewrittenPackageCache } from '@embroider/shared-internals'; import makeDebug from 'debug'; import assertNever from 'assert-never'; @@ -242,7 +242,7 @@ export class Resolver { return resolution; } - private logicalPackage(owningPackage: V2Package, file: string): V2Package { + private logicalPackage(owningPackage: Package, file: string): Package { let logicalLocation = this.reverseSearchAppTree(owningPackage, file); if (logicalLocation) { let pkg = this.packageCache.get(logicalLocation.owningEngine.root); @@ -970,7 +970,7 @@ export class Resolver { if (pkg.name === packageName) { // we found a self-import - if (pkg.meta['auto-upgraded']) { + if (pkg.meta?.['auto-upgraded']) { // auto-upgraded packages always get automatically adjusted. They never // supported fancy package.json exports features so this direct mapping // to the root is always right. @@ -1106,7 +1106,7 @@ export class Resolver { // choices about what it can import let logicalPackage = this.logicalPackage(pkg, fromFile); - if (logicalPackage.meta['auto-upgraded'] && !logicalPackage.hasDependency('ember-auto-import')) { + if (logicalPackage.meta?.['auto-upgraded'] && !logicalPackage.hasDependency('ember-auto-import')) { try { let dep = this.packageCache.resolve(packageName, logicalPackage); if (!dep.isEmberAddon()) { @@ -1425,7 +1425,7 @@ export class Resolver { // dependencies, or importing your own name from within a monorepo (which will // work because of the symlinking) without setting up "exports" (which makes // your own name reliably resolvable) -function reliablyResolvable(pkg: V2Package, packageName: string) { +function reliablyResolvable(pkg: Package, packageName: string) { if (pkg.hasDependency(packageName)) { return true; } diff --git a/packages/core/src/packager.ts b/packages/core/src/packager.ts index c12216b5c..8f4840e71 100644 --- a/packages/core/src/packager.ts +++ b/packages/core/src/packager.ts @@ -1,6 +1,4 @@ -import type { AppMeta } from '@embroider/shared-internals'; import { tmpdir } from '@embroider/shared-internals'; -import { readFileSync } from 'fs-extra'; import { cloneDeep } from 'lodash'; import { join } from 'path'; @@ -90,14 +88,6 @@ export function applyVariantToBabelConfig(variant: Variant, babelConfig: any) { return babelConfig; } -/** - * Get the app meta-data for a package - */ -export function getAppMeta(pathToVanillaApp: string) { - let pkg = JSON.parse(readFileSync(join(pathToVanillaApp, 'package.json'), 'utf8')); - return pkg as unknown as { name: string; 'ember-addon': AppMeta }; -} - /** * Get the path to a cache directory in the recommended location * diff --git a/packages/core/tests/packager.test.ts b/packages/core/tests/packager.test.ts deleted file mode 100644 index d1aa99bde..000000000 --- a/packages/core/tests/packager.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import type { AppMeta } from '../src'; -import { getAppMeta, getPackagerCacheDir } from '../src'; -import { tmpdir } from 'os'; -import { writeJSONSync, realpathSync } from 'fs-extra'; -import { join } from 'path'; -import * as tmp from 'tmp'; - -tmp.setGracefulCleanup(); - -describe('getAppMeta', () => { - let name: string, removeCallback: tmp.DirResult['removeCallback']; - - beforeEach(() => { - ({ name, removeCallback } = tmp.dirSync()); - - writeJSONSync(join(name, 'package.json'), { - 'ember-addon': { - version: 2, - type: 'app', - 'auto-upgraded': true, - }, - }); - }); - - afterEach(() => { - removeCallback(); - }); - - test('reading the app metadata from a package', () => { - const meta: AppMeta = getAppMeta(name)['ember-addon']; - expect(meta).toMatchObject({ - version: 2, - type: 'app', - 'auto-upgraded': true, - }); - }); -}); - -describe('getPackagerCacheDir', () => { - test('getting the path to a cache directory', () => { - const cacheDir = getPackagerCacheDir('foo'); - expect(cacheDir).toBe(join(realpathSync(tmpdir()), 'embroider', 'foo')); - }); -}); diff --git a/packages/shared-internals/src/colocation.ts b/packages/shared-internals/src/colocation.ts index 2cef79f53..d6630b74c 100644 --- a/packages/shared-internals/src/colocation.ts +++ b/packages/shared-internals/src/colocation.ts @@ -40,7 +40,7 @@ export function isInComponents(url: string, packageCache: Pick; 'ember-addon': | AddonMeta - | AppMeta | { main?: string; // version?: 1; - type?: 'addon' | 'app'; paths?: string[]; before?: string | string[]; after?: string | string[]; diff --git a/packages/shared-internals/src/package.ts b/packages/shared-internals/src/package.ts index 3d7321b7f..017126a5e 100644 --- a/packages/shared-internals/src/package.ts +++ b/packages/shared-internals/src/package.ts @@ -2,7 +2,7 @@ import { Memoize } from 'typescript-memoize'; import { readFileSync, existsSync } from 'fs-extra'; import { join, extname } from 'path'; import get from 'lodash/get'; -import type { AddonMeta, AppMeta, PackageInfo } from './metadata'; +import type { AddonMeta, PackageInfo } from './metadata'; import type PackageCache from './package-cache'; import flatMap from 'lodash/flatMap'; @@ -40,8 +40,8 @@ export default class Package { // order here matters because we rely on it in categorizeDependency private dependencyKeys: ('dependencies' | 'devDependencies' | 'peerDependencies')[]; - constructor(readonly root: string, protected packageCache: PackageCache, private isApp: boolean) { - this.dependencyKeys = isApp + constructor(readonly root: string, protected packageCache: PackageCache, private _isApp: boolean) { + this.dependencyKeys = _isApp ? ['dependencies', 'devDependencies', 'peerDependencies'] : ['dependencies', 'peerDependencies']; } @@ -71,30 +71,16 @@ export default class Package { } } if (forcedV2Packages().includes(json.name)) { - let defaults: AddonMeta | AppMeta; - if (this.isApp) { - defaults = { - version: 2, - type: 'app', - assets: [], - 'root-url': '/', - }; - } else { - defaults = { - version: 2, - type: 'addon', - }; - } + let defaults: AddonMeta = { + version: 2, + }; json['ember-addon'] = Object.assign(defaults, json['ember-addon']); } return json; } - get meta(): AddonMeta | AppMeta | undefined { + get meta(): AddonMeta | undefined { let m = this.packageJSON['ember-addon']; - if (this.isV2App()) { - return m as unknown as AppMeta; - } if (this.isV2Addon()) { return m as AddonMeta; } @@ -106,7 +92,7 @@ export default class Package { } isEngine(): boolean { - if (this.isApp) { + if (this.isApp()) { // an app is implicitly an engine return true; } @@ -118,23 +104,20 @@ export default class Package { return this.isEngine() && Boolean(get(this.packageJSON, 'ember-addon.lazy-engine')); } - isV2Ember(): this is V2Package { - return ( - get(this.packageJSON, 'ember-addon.version') === 2 && - (get(this.packageJSON, 'ember-addon.type') === 'app' || this.isEmberAddon()) - ); + isV2Ember(): boolean { + return this.isApp() || this.isV2Addon(); } - isV2App(): this is V2AppPackage { - return this.isV2Ember() && this.packageJSON['ember-addon'].type === 'app'; + isApp(): boolean { + return this._isApp; } needsLooseResolving(): boolean { - return this.isV2App() || ((this.isV2Addon() && this.meta['auto-upgraded']) ?? false); + return this.isApp() || ((this.isV2Addon() && this.meta['auto-upgraded']) ?? false); } isV2Addon(): this is V2AddonPackage { - return this.isV2Ember() && this.packageJSON['ember-addon'].type === 'addon'; + return this.isEmberAddon() && this.packageJSON['ember-addon']?.version === 2; } findDescendants(filter?: (pkg: Package) => boolean): Package[] { @@ -283,14 +266,6 @@ export interface PackageConstructor { new (root: string, mayUseDevDeps: boolean, packageCache: PackageCache): Package; } -export interface V2Package extends Package { - meta: AddonMeta | AppMeta; -} - export interface V2AddonPackage extends Package { meta: AddonMeta; } - -export interface V2AppPackage extends Package { - meta: AppMeta; -} diff --git a/packages/shared-internals/src/rewritten-package-cache.ts b/packages/shared-internals/src/rewritten-package-cache.ts index 914111029..fe9da902d 100644 --- a/packages/shared-internals/src/rewritten-package-cache.ts +++ b/packages/shared-internals/src/rewritten-package-cache.ts @@ -1,5 +1,5 @@ import PackageCache, { type PackageCachePublicAPI } from './package-cache'; -import type { V2AddonPackage, V2AppPackage, V2Package } from './package'; +import type { V2AddonPackage } from './package'; import Package from './package'; import { existsSync, readJSONSync, realpathSync } from 'fs-extra'; import { resolve } from 'path'; @@ -238,12 +238,12 @@ class WrappedPackage implements PackageTheGoodParts { return this.plainPkg.isLazyEngine(); } - isV2Ember(): this is V2Package { + isV2Ember(): boolean { return this.plainPkg.isV2Ember(); } - isV2App(): this is V2AppPackage { - return this.plainPkg.isV2App(); + isApp(): boolean { + return this.plainPkg.isApp(); } isV2Addon(): this is V2AddonPackage { diff --git a/packages/shared-internals/tests/template-colocation-plugin.test.ts b/packages/shared-internals/tests/template-colocation-plugin.test.ts index 9ccf535c1..973e66c15 100644 --- a/packages/shared-internals/tests/template-colocation-plugin.test.ts +++ b/packages/shared-internals/tests/template-colocation-plugin.test.ts @@ -3,7 +3,6 @@ import { join } from 'path'; import tmp from 'tmp'; import { writeFileSync } from 'fs'; import { writeJSONSync } from 'fs-extra'; -import type { AppMeta } from '../src'; tmp.setGracefulCleanup(); @@ -41,12 +40,6 @@ describe('template-colocation-plugin', () => { ]; writeJSONSync(join(name, 'package.json'), { name: 'sample-package', - keywords: ['ember-addon'], - 'ember-addon': { - version: 2, - type: 'app', - 'auto-upgraded': true, - } as AppMeta, }); }); diff --git a/packages/webpack/src/ember-webpack.ts b/packages/webpack/src/ember-webpack.ts index 9a9b535bd..aa1ac5512 100644 --- a/packages/webpack/src/ember-webpack.ts +++ b/packages/webpack/src/ember-webpack.ts @@ -9,8 +9,8 @@ getting script vs module context correct). */ -import type { AppMeta, BundleSummary, Packager, PackagerConstructor, Variant, ResolverOptions } from '@embroider/core'; -import { HTMLEntrypoint, getAppMeta, getPackagerCacheDir, getOrCreate } from '@embroider/core'; +import type { BundleSummary, Packager, PackagerConstructor, Variant, ResolverOptions } from '@embroider/core'; +import { HTMLEntrypoint, getPackagerCacheDir, getOrCreate } from '@embroider/core'; import { locateEmbroiderWorkingDir, RewrittenPackageCache, tmpdir } from '@embroider/shared-internals'; import type { Configuration, RuleSetUseItem, WebpackPluginInstance } from 'webpack'; import webpack from 'webpack'; @@ -45,7 +45,7 @@ type MinifyOptions = NonNullable = class Webpack implements Packager } private examineApp(): AppInfo { + // @ts-expect-error webpack is not updated to work on @embroider/core 4.x let meta = getAppMeta(this.pathToVanillaApp); let rootURL = meta['ember-addon']['root-url']; let entrypoints = []; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0ba37dc0e..93af31d4f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -221,9 +221,6 @@ importers: '@types/babel__code-frame': specifier: ^7.0.2 version: 7.0.6 - '@types/yargs': - specifier: ^17.0.3 - version: 17.0.33 assert-never: specifier: ^1.1.0 version: 1.3.0 @@ -320,9 +317,6 @@ importers: walk-sync: specifier: ^3.0.0 version: 3.0.0 - yargs: - specifier: ^17.0.1 - version: 17.7.2 devDependencies: '@embroider/core': specifier: workspace:^ diff --git a/tests/scenarios/compat-resolver-test.ts b/tests/scenarios/compat-resolver-test.ts index db49aca47..5c48a609b 100644 --- a/tests/scenarios/compat-resolver-test.ts +++ b/tests/scenarios/compat-resolver-test.ts @@ -1,4 +1,3 @@ -import type { AppMeta } from '@embroider/shared-internals'; import { Transpiler } from '@embroider/test-support'; import type { ExpectFile } from '@embroider/test-support/file-assertions/qunit'; import { expectFilesAt } from '@embroider/test-support/file-assertions/qunit'; @@ -14,17 +13,8 @@ const { module: Qmodule, test } = QUnit; Scenarios.fromProject(() => new Project()) .map('compat-resolver-test', app => { - let appMeta: AppMeta = { - type: 'app', - version: 2, - 'auto-upgraded': true, - assets: ['index.html'], - 'root-url': '/', - }; app.pkg = { name: 'my-app', - keywords: ['ember-addon'], - 'ember-addon': appMeta as any, }; app.mergeFiles({ 'index.html': '', diff --git a/tests/scenarios/core-resolver-test.ts b/tests/scenarios/core-resolver-test.ts index e270c89a3..bc7d61f7d 100644 --- a/tests/scenarios/core-resolver-test.ts +++ b/tests/scenarios/core-resolver-test.ts @@ -1,4 +1,4 @@ -import type { AddonMeta, AppMeta, RewrittenPackageIndex } from '@embroider/shared-internals'; +import type { AddonMeta, RewrittenPackageIndex } from '@embroider/shared-internals'; import { outputFileSync, readJsonSync, writeJSONSync } from 'fs-extra'; import { resolve } from 'path'; import QUnit from 'qunit'; @@ -13,17 +13,8 @@ const { module: Qmodule, test } = QUnit; Scenarios.fromProject(() => new Project()) .map('core-resolver-test', app => { - let appMeta: AppMeta = { - type: 'app', - version: 2, - 'auto-upgraded': true, - assets: ['index.html'], - 'root-url': '/', - }; app.pkg = { name: 'my-app', - keywords: ['ember-addon'], - 'ember-addon': appMeta as any, exports: { './*': './*', './tests/*': './tests/*', @@ -98,7 +89,7 @@ Scenarios.fromProject(() => new Project()) function addonPackageJSON(name = 'my-addon', addonMeta?: Partial) { return JSON.stringify( (() => { - let meta: AddonMeta = { type: 'addon', version: 2, 'auto-upgraded': true, ...(addonMeta ?? {}) }; + let meta: AddonMeta = { version: 2, 'auto-upgraded': true, ...(addonMeta ?? {}) }; return { name, keywords: ['ember-addon'], @@ -203,7 +194,12 @@ Scenarios.fromProject(() => new Project()) 'node_modules/my-addon/package.json': addonPackageJSON('my-addon', opts?.addonMeta), }); - expectAudit = await assert.audit({ app: app.dir, 'reuse-build': true }); + expectAudit = await assert.audit({ + app: app.dir, + 'reuse-build': true, + entrypoints: ['index.html'], + rootURL: '/', + }); }; });