diff --git a/package.json b/package.json index 32567e2a..5eb69bcd 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,15 @@ "type": "git", "url": "git@github.com:ember-fastboot/ember-cli-fastboot.git" }, - "workspaces": [ - "packages/*", - "test-packages/*" - ], + "workspaces": { + "packages": [ + "packages/*", + "test-packages/*" + ], + "nohoist": [ + "**/ember-cli-addon-tests" + ] + }, "scripts": { "test": "npm-run-all test:*", "test:ember-cli-fastboot": "yarn workspace ember-cli-fastboot test:ember", diff --git a/packages/ember-cli-fastboot/fix-node-modules.mjs b/packages/ember-cli-fastboot/fix-node-modules.mjs index fdd4b85a..96c08117 100644 --- a/packages/ember-cli-fastboot/fix-node-modules.mjs +++ b/packages/ember-cli-fastboot/fix-node-modules.mjs @@ -12,6 +12,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const packagesDir = path.resolve(__dirname, '../../packages'); const nodeModulesDir = path.resolve(__dirname, 'node_modules'); +const precookedDir = path.resolve(__dirname, 'tmp', 'precooked_node_modules'); // eslint-disable-next-line no-undef const shouldRestore = process.argv[2]; @@ -29,11 +30,16 @@ Options: function run(shouldRestore) { ['fastboot', 'fastboot-express-middleware'].forEach((packageName) => { const nodeModulesPackageDir = path.join(nodeModulesDir, packageName); + const precookedPackageDir = path.join(precookedDir, packageName); const workspacesPackageDir = path.resolve(packagesDir, packageName); if (fs.existsSync(nodeModulesPackageDir)) { console.log(chalk.blue(`remove ${nodeModulesPackageDir}`)); fs.removeSync(nodeModulesPackageDir); } + if (fs.existsSync(precookedPackageDir)) { + console.log(chalk.blue(`remove ${precookedPackageDir}`)); + fs.removeSync(precookedPackageDir); + } if (!shouldRestore) { console.log( chalk.green( @@ -41,6 +47,10 @@ function run(shouldRestore) { ) ); fs.symlinkSync(workspacesPackageDir, nodeModulesPackageDir, 'dir'); + console.log( + chalk.green(`symlink ${precookedPackageDir} -> ${workspacesPackageDir}`) + ); + fs.symlinkSync(workspacesPackageDir, precookedPackageDir, 'dir'); } }); } diff --git a/packages/ember-cli-fastboot/package.json b/packages/ember-cli-fastboot/package.json index 7b1af0a7..3fa65f75 100644 --- a/packages/ember-cli-fastboot/package.json +++ b/packages/ember-cli-fastboot/package.json @@ -22,10 +22,10 @@ "release": "release-it", "lint:js:fix": "eslint . --fix", "start": "ember serve", - "test": "npm-run-all lint test:*", - "test:mocha": "node fix-node-modules.mjs && mocha && node fix-node-modules.mjs -r", + "pretest:precook": "node node_modules/ember-cli-addon-tests/scripts/precook-node-modules.js", + "test": "npm-run-all lint pretest:* test:*", + "test:mocha": "node fix-node-modules.mjs && mocha", "test:ember": "ember test", - "test:precook": "node node_modules/ember-cli-addon-tests/scripts/precook-node-modules.js", "test:ember-compatibility": "ember try:each" }, "dependencies": { @@ -45,9 +45,13 @@ "fs-extra": "^10.0.0", "json-stable-stringify": "^1.0.1", "md5-hex": "^3.0.1", + "node-fetch": "^2.6.7", "recast": "^0.19.1", "silent-error": "^1.1.1" }, + "fastbootDependencies": [ + "node-fetch" + ], "devDependencies": { "@ember/optional-features": "^2.0.0", "@ember/test-helpers": "^2.6.0", diff --git a/packages/ember-cli-fastboot/test/fastboot-config-test.js b/packages/ember-cli-fastboot/test/fastboot-config-test.js index 4c8caa9b..19202c76 100644 --- a/packages/ember-cli-fastboot/test/fastboot-config-test.js +++ b/packages/ember-cli-fastboot/test/fastboot-config-test.js @@ -16,15 +16,15 @@ describe('FastBoot config', function () { return app .create('fastboot-config', { - emberVersion: 'latest', - emberDataVersion: 'latest', + emberVersion: '~3.28.12', + emberDataVersion: '~3.28.12', }) .then(function () { app.editPackageJSON((pkg) => { delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` - pkg.fastbootDependencies = ['crypto']; + pkg.fastbootDependencies = ['node-fetch', 'crypto']; }); return app.run('npm', 'install'); }) diff --git a/packages/ember-cli-fastboot/test/fastboot-location-config-test.js b/packages/ember-cli-fastboot/test/fastboot-location-config-test.js index d2385a0e..63a0797c 100644 --- a/packages/ember-cli-fastboot/test/fastboot-location-config-test.js +++ b/packages/ember-cli-fastboot/test/fastboot-location-config-test.js @@ -16,15 +16,15 @@ describe('FastBootLocation Configuration', function () { return app .create('fastboot-location-config', { - emberVersion: 'latest', - emberDataVersion: 'latest', + emberVersion: '~3.28.12', + emberDataVersion: '~3.28.12', }) .then(function () { app.editPackageJSON((pkg) => { delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` - pkg.fastbootDependencies = ['crypto']; + pkg.fastbootDependencies = ['node-fetch', 'crypto']; }); return app.run('npm', 'install'); }) diff --git a/packages/ember-cli-fastboot/test/fastboot-location-test.js b/packages/ember-cli-fastboot/test/fastboot-location-test.js index 9acb3c9f..99c4540b 100644 --- a/packages/ember-cli-fastboot/test/fastboot-location-test.js +++ b/packages/ember-cli-fastboot/test/fastboot-location-test.js @@ -15,15 +15,15 @@ describe('FastBootLocation', function () { return app .create('fastboot-location', { - emberVersion: 'latest', - emberDataVersion: 'latest', + emberVersion: '~3.28.12', + emberDataVersion: '~3.28.12', }) .then(function () { app.editPackageJSON((pkg) => { delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` - pkg.fastbootDependencies = ['crypto']; + pkg.fastbootDependencies = ['node-fetch', 'crypto']; }); return app.run('npm', 'install'); }) diff --git a/packages/ember-cli-fastboot/test/package-json-test.js b/packages/ember-cli-fastboot/test/package-json-test.js index 97c06a0a..0f98eb67 100644 --- a/packages/ember-cli-fastboot/test/package-json-test.js +++ b/packages/ember-cli-fastboot/test/package-json-test.js @@ -18,15 +18,15 @@ describe('generating package.json', function () { before(function () { return customApp .create('customized-outputpaths', { - emberVersion: 'latest', - emberDataVersion: 'latest', + emberVersion: '~3.28.12', + emberDataVersion: '~3.28.12', }) .then(function () { customApp.editPackageJSON((pkg) => { delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` - pkg.fastbootDependencies = ['crypto']; + pkg.fastbootDependencies = ['node-fetch', 'crypto']; }); return customApp.run('npm', 'install'); }) diff --git a/packages/ember-cli-fastboot/test/request-details-test.js b/packages/ember-cli-fastboot/test/request-details-test.js index a38a0020..278392cf 100644 --- a/packages/ember-cli-fastboot/test/request-details-test.js +++ b/packages/ember-cli-fastboot/test/request-details-test.js @@ -7,28 +7,36 @@ const RSVP = require('rsvp'); const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; const request = RSVP.denodeify(require('request')); -function injectMiddlewareAddon(app) { +async function injectMiddlewareAddon(app) { app.editPackageJSON(function (pkg) { pkg.devDependencies['body-parser'] = process.env.npm_package_devDependencies_body_parser; pkg.dependencies = pkg.dependencies || {}; - pkg.dependencies['fastboot'] = `file:${path.resolve( - __dirname, - '../../fastboot' - )}`; - pkg.dependencies['fastboot-express-middleware'] = `file:${path.resolve( - __dirname, - '../../fastboot-express-middleware' - )}`; pkg['ember-addon'] = { paths: ['lib/post-middleware'], }; delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` - pkg.fastbootDependencies = ['crypto']; + pkg.fastbootDependencies = ['node-fetch', 'crypto']; + }); + await app.run('npm', 'install', '--no-package-lock'); + await app.run( + 'ln', + '-s', + path.resolve(__dirname, '../../fastboot'), + path.resolve(app.path, 'node_modules/fastboot') + ); + await app.run( + 'ln', + '-s', + path.resolve(__dirname, '../../fastboot-express-middleware'), + path.resolve(app.path, 'node_modules/fastboot-express-middleware') + ); + app.editPackageJSON(function (pkg) { + pkg.dependencies['fastboot'] = '*'; + pkg.dependencies['fastboot-express-middleware'] = '*'; }); - return app.run('npm', 'install'); } describe('request details', function () { @@ -41,8 +49,8 @@ describe('request details', function () { return app .create('request', { - emberVersion: 'latest', - emberDataVersion: 'latest', + emberVersion: '~3.28.12', + emberDataVersion: '~3.28.12', }) .then(() => injectMiddlewareAddon(app)) .then(function () { diff --git a/packages/ember-cli-fastboot/test/root-url-test.js b/packages/ember-cli-fastboot/test/root-url-test.js index a0f97605..d787496e 100644 --- a/packages/ember-cli-fastboot/test/root-url-test.js +++ b/packages/ember-cli-fastboot/test/root-url-test.js @@ -16,15 +16,15 @@ describe('rootUrl acceptance', function () { return app .create('root-url', { - emberVersion: 'latest', - emberDataVersion: 'latest', + emberVersion: '~3.28.12', + emberDataVersion: '~3.28.12', }) .then(function () { app.editPackageJSON((pkg) => { delete pkg.devDependencies['ember-fetch']; delete pkg.devDependencies['ember-welcome-page']; // needed because @ember-data/store does `FastBoot.require('crypto')` - pkg.fastbootDependencies = ['crypto']; + pkg.fastbootDependencies = ['node-fetch', 'crypto']; }); return app.run('npm', 'install'); })