Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into audit
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Nov 3, 2020
2 parents ebe58d5 + 45f2a7c commit 91dd464
Show file tree
Hide file tree
Showing 28 changed files with 161 additions and 91 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Embroider Changelog

## 0.29.0 (2020-10-27)

- BUGFIX: dependencySatisfies macro fixes by @rwjblue

## 0.28.0 (2020-10-21)

- BUGFIX: fastboot hostWhiteList support by @simonihmig
Expand Down
12 changes: 6 additions & 6 deletions packages/addon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/addon",
"version": "0.28.0",
"version": "0.29.0",
"description": "The default blueprint for ember-cli addons.",
"keywords": [
"ember-addon"
Expand Down Expand Up @@ -28,11 +28,11 @@
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@embroider/compat": "0.28.0",
"@embroider/core": "0.28.0",
"@embroider/test-setup": "0.28.0",
"@embroider/test-support": "0.28.0",
"@embroider/webpack": "0.28.0",
"@embroider/compat": "0.29.0",
"@embroider/core": "0.29.0",
"@embroider/test-setup": "0.29.0",
"@embroider/test-support": "0.29.0",
"@embroider/webpack": "0.29.0",
"@glimmer/component": "^1.0.1",
"@glimmer/tracking": "^1.0.1",
"babel-eslint": "^10.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-loader-7/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/babel-loader-7",
"version": "0.28.0",
"version": "0.29.0",
"repository": {
"type": "git",
"url": "https://github.com/embroider-build/embroider.git",
Expand Down
12 changes: 6 additions & 6 deletions packages/compat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/compat",
"version": "0.28.0",
"version": "0.29.0",
"private": false,
"description": "Backward compatibility layer for the Embroider build system.",
"repository": {
Expand Down Expand Up @@ -30,7 +30,7 @@
"@babel/preset-env": "^7.12.1",
"@babel/traverse": "^7.12.1",
"@babel/types": "^7.12.1",
"@embroider/macros": "0.28.0",
"@embroider/macros": "0.29.0",
"@types/babel__code-frame": "^7.0.2",
"@types/yargs": "^15.0.9",
"assert-never": "^1.1.0",
Expand All @@ -56,7 +56,7 @@
"pkg-up": "^2.0.0",
"resolve": "^1.8.1",
"resolve-package-path": "^1.2.2",
"semver": "^5.5.0",
"semver": "^7.3.2",
"symlink-or-copy": "^1.2.0",
"tree-sync": "^2.0.0",
"typescript-memoize": "^1.0.0-alpha.3",
Expand All @@ -65,7 +65,7 @@
},
"devDependencies": {
"@embroider/sample-transforms": "0.0.0",
"@embroider/test-support": "0.28.0",
"@embroider/test-support": "0.29.0",
"@types/babel__core": "^7.1.10",
"@types/babel__generator": "^7.6.2",
"@types/babel__template": "^7.0.3",
Expand All @@ -77,13 +77,13 @@
"@types/lodash": "^4.14.116",
"@types/node": "^10.5.2",
"@types/resolve": "^0.0.8",
"@types/semver": "^5.5.0",
"@types/semver": "^7.3.4",
"@types/strip-bom": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^2.1.0",
"typescript": "~4.0.0"
},
"peerDependencies": {
"@embroider/core": "0.28.0"
"@embroider/core": "0.29.0"
},
"engines": {
"node": "10.* || 12.* || >= 14"
Expand Down
10 changes: 5 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/core",
"version": "0.28.0",
"version": "0.29.0",
"private": false,
"description": "A build system for EmberJS applications.",
"repository": {
Expand All @@ -26,7 +26,7 @@
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/traverse": "^7.12.1",
"@babel/types": "^7.12.1",
"@embroider/macros": "0.28.0",
"@embroider/macros": "0.29.0",
"assert-never": "^1.1.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"broccoli-persistent-filter": "^2.2.2",
Expand All @@ -45,15 +45,15 @@
"pkg-up": "^2.0.0",
"resolve": "^1.8.1",
"resolve-package-path": "^1.2.2",
"semver": "^5.5.0",
"semver": "^7.3.2",
"strip-bom": "^3.0.0",
"typescript-memoize": "^1.0.0-alpha.3",
"walk-sync": "^1.1.3",
"wrap-legacy-hbs-plugin-if-needed": "^1.0.1"
},
"devDependencies": {
"@embroider/sample-transforms": "0.0.0",
"@embroider/test-support": "0.28.0",
"@embroider/test-support": "0.29.0",
"@types/babel__core": "^7.1.10",
"@types/debug": "^0.0.31",
"@types/filesize": "^4.1.0",
Expand All @@ -62,7 +62,7 @@
"@types/lodash": "^4.14.116",
"@types/node": "^10.5.2",
"@types/resolve": "^0.0.8",
"@types/semver": "^5.5.0",
"@types/semver": "^7.3.4",
"@types/strip-bom": "^3.0.0",
"@types/tmp": "^0.1.0",
"fixturify": "^1.2.0",
Expand Down
9 changes: 5 additions & 4 deletions packages/macros/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/macros",
"version": "0.28.0",
"version": "0.29.0",
"private": false,
"description": "Standardized build-time macros for ember apps.",
"keywords": [
Expand All @@ -27,20 +27,21 @@
"@babel/core": "^7.12.3",
"@babel/traverse": "^7.12.1",
"@babel/types": "^7.12.1",
"@embroider/core": "0.28.0",
"@embroider/core": "0.29.0",
"assert-never": "^1.1.0",
"ember-cli-babel": "^7.23.0",
"lodash": "^4.17.10",
"resolve": "^1.8.1",
"semver": "^5.6.0"
"semver": "^7.3.2"
},
"devDependencies": {
"@embroider/test-support": "0.28.0",
"@embroider/test-support": "0.29.0",
"@types/babel__core": "^7.1.10",
"@types/babel__generator": "^7.6.2",
"@types/babel__template": "^7.0.3",
"@types/node": "^10.5.2",
"@types/resolve": "^0.0.8",
"@types/semver": "^7.3.4",
"typescript": "~4.0.0"
},
"engines": {
Expand Down
4 changes: 3 additions & 1 deletion packages/macros/src/babel/dependency-satisfies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export default function dependencySatisfies(path: NodePath<CallExpression>, stat
return false;
}
let version = packageCache.resolve(packageName.value, us).version;
return satisfies(version, range.value);
return satisfies(version, range.value, {
includePrerelease: true,
});
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
throw err;
Expand Down
13 changes: 4 additions & 9 deletions packages/macros/src/glimmer/dependency-satisfies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { satisfies, coerce } from 'semver';
import { satisfies } from 'semver';
import { PackageCache } from '@embroider/core';

let packageCache = PackageCache.shared('embroider-stage3');
Expand Down Expand Up @@ -36,14 +36,9 @@ export default function dependencySatisfies(
}

if (pkg) {
// we coerce here because we want versions like '3.9.0-beta.0' to satisfy
// constraints like '> 3.8'. The coerce method is pretty aggressive, but
// honestly if people areputting things into their package.json version that
// are going to coerce weirdly, that's on them.
let version = coerce(pkg.version);
if (version != null) {
return satisfies(version, range);
}
return satisfies(pkg.version, range, {
includePrerelease: true,
});
}
return false;
}
36 changes: 34 additions & 2 deletions packages/macros/tests/babel/dependency-satisfies.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import { allBabelVersions, runDefault } from './helpers';
import * as path from 'path';
import { allBabelVersions, Project, runDefault } from './helpers';

const ROOT = process.cwd();

describe(`dependencySatisfies`, function () {
allBabelVersions(function (transform: (code: string) => string) {
let project: Project;

afterEach(() => {
if (project) {
project.dispose();
}

process.chdir(ROOT);
});

allBabelVersions(function (transform: (code: string, options?: object) => string) {
test('is satisfied', () => {
let code = transform(`
import { dependencySatisfies } from '@embroider/macros';
Expand Down Expand Up @@ -91,5 +104,24 @@ describe(`dependencySatisfies`, function () {
`);
}).toThrow(/the first argument to dependencySatisfies must be a string literal/);
});

test('it considers prereleases (otherwise within the range) as allowed', () => {
project = new Project('test-app', '1.0.0');
project.addDevDependency('foo', '1.1.0-beta.1');
project.writeSync();

process.chdir(project.baseDir);

let code = transform(
`
import { dependencySatisfies } from '@embroider/macros';
export default function() {
return dependencySatisfies('foo', '^1.0.0');
}
`,
{ filename: path.join(project.baseDir, 'foo.js') }
);
expect(runDefault(code)).toBe(true);
});
});
});
4 changes: 2 additions & 2 deletions packages/macros/tests/babel/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MacrosConfig } from '../..';
import { join, dirname } from 'path';
import { allBabelVersions as allBabel, runDefault, Transform, toCJS } from '@embroider/test-support';
import { allBabelVersions as allBabel, Project, runDefault, Transform, toCJS } from '@embroider/test-support';
import { readFileSync } from 'fs';
import { Script, createContext } from 'vm';
import { explicitRelative } from '@embroider/core';

export { runDefault };
export { runDefault, Project };

const runtimeFilename = join(__dirname, '../../src/addon/runtime.js');

Expand Down
29 changes: 27 additions & 2 deletions packages/macros/tests/glimmer/dependency-satisfies.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { templateTests } from './helpers';
import { Project, templateTests } from './helpers';
import * as path from 'path';

const ROOT = process.cwd();
describe('dependency satisfies', () => {
templateTests((transform: (code: string) => string) => {
let project: Project;

afterEach(() => {
if (project) {
project.dispose();
}

process.chdir(ROOT);
});

templateTests((transform: (code: string, options?: object) => string) => {
test('in content position', () => {
let result = transform(`{{macroDependencySatisfies 'qunit' '^2.8.0'}}`);
expect(result).toEqual('{{true}}');
Expand Down Expand Up @@ -33,5 +45,18 @@ describe('dependency satisfies', () => {
transform(`{{macroDependencySatisfies someDep "*"}}`);
}).toThrow(/all arguments to macroDependencySatisfies must be string literals/);
});

test('it considers prereleases (otherwise within the range) as allowed', () => {
project = new Project('test-app', '1.0.0');
project.addDevDependency('foo', '1.1.0-beta.1');
project.writeSync();

process.chdir(project.baseDir);

let result = transform(`{{macroDependencySatisfies 'foo' '^1.0.0'}}`, {
filename: path.join(project.baseDir, 'foo.js'),
});
expect(result).toEqual('{{true}}');
});
});
});
14 changes: 11 additions & 3 deletions packages/macros/tests/glimmer/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { TemplateCompiler } from '@embroider/core';
import { emberTemplateCompilerPath } from '@embroider/test-support';
import { emberTemplateCompilerPath, Project } from '@embroider/test-support';
import { MacrosConfig } from '../..';
import { join } from 'path';
const compilerPath = emberTemplateCompilerPath();

export { Project };

type CreateTestsWithConfig = (transform: (templateContents: string) => string, config: MacrosConfig) => void;
type CreateTests = (transform: (templateContents: string) => string) => void;

interface TemplateTransformOptions {
filename?: string;
}

export function templateTests(createTests: CreateTestsWithConfig | CreateTests) {
let { plugins, setConfig } = MacrosConfig.astPlugins();
let config = MacrosConfig.for({});
Expand All @@ -18,8 +24,10 @@ export function templateTests(createTests: CreateTestsWithConfig | CreateTests)
ast: plugins,
},
});
let transform = (templateContents: string) => {
return compiler.applyTransforms(join(__dirname, 'sample.hbs'), templateContents);
let transform = (templateContents: string, options: TemplateTransformOptions = {}) => {
let filename = options.filename ?? join(__dirname, 'sample.hbs');

return compiler.applyTransforms(filename, templateContents);
};
if (createTests.length === 2) {
(createTests as CreateTestsWithConfig)(transform, config);
Expand Down
12 changes: 6 additions & 6 deletions packages/router/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/router",
"version": "0.28.0",
"version": "0.29.0",
"description": "Lazy loading router",
"keywords": [
"ember-addon"
Expand Down Expand Up @@ -28,15 +28,15 @@
"test:classic": "CLASSIC=true ember test --test-port=0"
},
"dependencies": {
"@embroider/macros": "0.28.0",
"@embroider/macros": "0.29.0",
"ember-cli-babel": "^7.23.0"
},
"devDependencies": {
"@ember/optional-features": "^0.7.0",
"@embroider/compat": "0.28.0",
"@embroider/core": "0.28.0",
"@embroider/test-support": "0.28.0",
"@embroider/webpack": "0.28.0",
"@embroider/compat": "0.29.0",
"@embroider/core": "0.29.0",
"@embroider/test-support": "0.29.0",
"@embroider/webpack": "0.29.0",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.10.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/test-setup/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/test-setup",
"version": "0.28.0",
"version": "0.29.0",
"repository": {
"type": "git",
"url": "https://github.com/embroider-build/embroider.git",
Expand All @@ -16,7 +16,7 @@
"resolve": "^1.17.0"
},
"devDependencies": {
"@embroider/compat": "0.28.0"
"@embroider/compat": "0.29.0"
},
"volta": {
"extends": "../../package.json"
Expand Down
Loading

0 comments on commit 91dd464

Please sign in to comment.