Skip to content

Commit

Permalink
Update Parcel to 1.10.0 (Fixes #216)
Browse files Browse the repository at this point in the history
* hash-key of parcel bundles is not environment independent (Fixes #180)
  • Loading branch information
tripodsan committed Sep 26, 2018
1 parent 8d5cca3 commit 6e21820
Show file tree
Hide file tree
Showing 7 changed files with 2,377 additions and 1,687 deletions.
3,948 changes: 2,326 additions & 1,622 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@adobe/htlengine": "^1.0.3",
"@adobe/hypermedia-pipeline": "^0.5.0",
"@adobe/openwhisk-loggly-wrapper": "^0.3.0",
"@adobe/parcel-plugin-htl": "0.8.0",
"@adobe/parcel-plugin-htl": "0.9.0",
"@adobe/petridish": "^1.4.4",
"archiver": "^3.0.0",
"calibre": "^1.1.1",
Expand All @@ -44,7 +44,7 @@
"object-hash": "^1.3.0",
"openwhisk": "3.17.0",
"opn": "^5.3.0",
"parcel-bundler": "^1.9.7",
"parcel-bundler": "^1.10.0",
"request": "^2.87.0",
"request-promise-native": "^1.0.5",
"shelljs": "^0.8.2",
Expand Down
44 changes: 19 additions & 25 deletions test/testBuildCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
const path = require('path');
const fs = require('fs-extra');
const assert = require('assert');
const md5 = require('../src/md5.js');
const { createTestRoot, assertFile, assertFileMissing } = require('./utils.js');
const { createTestRoot, assertFile } = require('./utils.js');

const BuildCommand = require('../src/build.cmd');

Expand All @@ -40,31 +39,29 @@ describe('Integration test for build', () => {

it('build command succeeds and produces files', async function test() {
this.timeout(5000);
const stylesCssName = `styles.${md5(path.resolve(TEST_DIR, 'src/component/styles.css')).slice(-8)}.css`;
const welcomeTxtName = `welcome.${md5(path.resolve(TEST_DIR, 'src/welcome.txt')).slice(-8)}.txt`;
await new BuildCommand()
.withFiles(['test/integration/src/**/*.htl'])
.withTargetDir(buildDir)
.withDistDir(distDir)
.withCacheEnabled(false)
.run();

await assertFile(path.resolve(buildDir, 'html.js'));
await assertFileMissing(path.resolve(buildDir, 'html.pre.js'));
await assertFile(path.resolve(buildDir, 'example_html.js'));
await assertFile(path.resolve(buildDir, 'component', 'html.js'));
await assertFile(path.resolve(distDir, welcomeTxtName));
await assertFile(path.resolve(distDir, stylesCssName));
await assertFile(path.resolve(testRoot, 'webroot', 'img', 'banner.png'));
assertFile(path.resolve(buildDir, 'html.js'));
assertFile(path.resolve(buildDir, 'html.pre.js'), true);
assertFile(path.resolve(buildDir, 'example_html.js'));
assertFile(path.resolve(buildDir, 'component', 'html.js'));
assertFile(path.resolve(distDir, 'welcome.bc53b44e.txt'));
assertFile(path.resolve(distDir, 'styles.28756636.css'));
assertFile(path.resolve(testRoot, 'webroot', 'img', 'banner.png'));

// test if manifest contains correct entries
const manifest = fs.readJsonSync(path.resolve(buildDir, 'manifest.json'));
assert.deepStrictEqual({
[stylesCssName]: {
'styles.28756636.css': {
hash: '52a3333296aaf35a6761cf3f5309528e',
size: 656,
},
[welcomeTxtName]: {
'welcome.bc53b44e.txt': {
hash: 'd6fc0d7dfc73e69219b8a3d110b69cb0',
size: 24,
},
Expand All @@ -73,9 +70,6 @@ describe('Integration test for build', () => {

it('build command with webroot puts files to correct place', async function test() {
this.timeout(5000);
const stylesCssName = `styles.${md5(path.resolve(TEST_DIR, 'src/component/styles.css')).slice(-8)}.css`;
const welcomeTxtName = `welcome.${md5(path.resolve(TEST_DIR, 'src/welcome.txt')).slice(-8)}.txt`;

await new BuildCommand()
.withFiles(['test/integration/src/**/*.htl'])
.withTargetDir(buildDir)
Expand All @@ -85,26 +79,26 @@ describe('Integration test for build', () => {
.run();

distDir = path.resolve(testRoot, 'webroot/dist');
await assertFile(path.resolve(buildDir, 'html.js'));
await assertFileMissing(path.resolve(buildDir, 'html.pre.js'));
await assertFile(path.resolve(buildDir, 'example_html.js'));
await assertFile(path.resolve(buildDir, 'component', 'html.js'));
await assertFile(path.resolve(distDir, welcomeTxtName));
await assertFile(path.resolve(distDir, stylesCssName));
await assertFile(path.resolve(testRoot, 'webroot', 'img', 'banner.png'));
assertFile(path.resolve(buildDir, 'html.js'));
assertFile(path.resolve(buildDir, 'html.pre.js'), true);
assertFile(path.resolve(buildDir, 'example_html.js'));
assertFile(path.resolve(buildDir, 'component', 'html.js'));
assertFile(path.resolve(distDir, 'welcome.bc53b44e.txt'));
assertFile(path.resolve(distDir, 'styles.28756636.css'));
assertFile(path.resolve(testRoot, 'webroot', 'img', 'banner.png'));

// test if manifest contains correct entries
const manifest = fs.readJsonSync(path.resolve(buildDir, 'manifest.json'));
assert.deepStrictEqual({
[stylesCssName]: {
'styles.28756636.css': {
hash: '52a3333296aaf35a6761cf3f5309528e',
size: 656,
},
'vendor/example.css': {
hash: 'f9806776872f8ff4940b806f94923c4d',
size: 658,
},
[welcomeTxtName]: {
'welcome.bc53b44e.txt': {
hash: 'd6fc0d7dfc73e69219b8a3d110b69cb0',
size: 24,
},
Expand Down
30 changes: 15 additions & 15 deletions test/testDemoCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ describe('Integration test for demo command', () => {
.withDirectory(testDir)
.withName('project1')
.run();
await assertFile(path.resolve(testDir, 'project1', '.gitignore'));
await assertFile(path.resolve(testDir, 'project1', 'src/html.htl'));
await assertFile(path.resolve(testDir, 'project1', 'src/html.pre.js'));
await assertFile(path.resolve(testDir, 'project1', 'index.md'));
await assertFile(path.resolve(testDir, 'project1', 'src/style.css'));
await assertFile(path.resolve(testDir, 'project1', 'src/favicon.ico'));
await assertFile(path.resolve(testDir, 'project1', 'helix_logo.png'));
assertFile(path.resolve(testDir, 'project1', '.gitignore'));
assertFile(path.resolve(testDir, 'project1', 'src/html.htl'));
assertFile(path.resolve(testDir, 'project1', 'src/html.pre.js'));
assertFile(path.resolve(testDir, 'project1', 'index.md'));
assertFile(path.resolve(testDir, 'project1', 'src/style.css'));
assertFile(path.resolve(testDir, 'project1', 'src/favicon.ico'));
assertFile(path.resolve(testDir, 'project1', 'helix_logo.png'));
}).timeout(3000);

it('demo type full creates all files', async () => {
Expand All @@ -52,14 +52,14 @@ describe('Integration test for demo command', () => {
.withName('project1')
.withType('full')
.run();
await assertFile(path.resolve(testDir, 'project1', '.gitignore'));
await assertFile(path.resolve(testDir, 'project1', 'src/html.htl'));
await assertFile(path.resolve(testDir, 'project1', 'src/html.pre.js'));
await assertFile(path.resolve(testDir, 'project1', 'index.md'));
await assertFile(path.resolve(testDir, 'project1', 'README.md'));
await assertFile(path.resolve(testDir, 'project1', 'src/bootstrap.min.css'));
await assertFile(path.resolve(testDir, 'project1', 'src/favicon.ico'));
await assertFile(path.resolve(testDir, 'project1', 'helix_logo.png'));
assertFile(path.resolve(testDir, 'project1', '.gitignore'));
assertFile(path.resolve(testDir, 'project1', 'src/html.htl'));
assertFile(path.resolve(testDir, 'project1', 'src/html.pre.js'));
assertFile(path.resolve(testDir, 'project1', 'index.md'));
assertFile(path.resolve(testDir, 'project1', 'README.md'));
assertFile(path.resolve(testDir, 'project1', 'src/bootstrap.min.css'));
assertFile(path.resolve(testDir, 'project1', 'src/favicon.ico'));
assertFile(path.resolve(testDir, 'project1', 'helix_logo.png'));
}).timeout(3000);

it('demo does not leave any files not checked in', async () => {
Expand Down
6 changes: 3 additions & 3 deletions test/testDeployCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('hlx deploy (Integration)', () => {
.withStrainFile(strainsFile)
.run();

await assertFile(strainsFile);
assertFile(strainsFile);
const firstrun = fs.readFileSync(strainsFile).toString();

await fs.remove(buildDir);
Expand All @@ -111,7 +111,7 @@ describe('hlx deploy (Integration)', () => {
.withStrainFile(strainsFile)
.run();

await assertFile(strainsFile);
assertFile(strainsFile);
const secondrun = fs.readFileSync(strainsFile).toString();
assert.equal(firstrun, secondrun, 'generated strains.yaml differs between first and second run');

Expand All @@ -128,7 +128,7 @@ describe('hlx deploy (Integration)', () => {
.withStrainFile(strainsFile)
.run();

await assertFile(strainsFile);
assertFile(strainsFile);
const thirdrun = fs.readFileSync(strainsFile).toString();
assert.notEqual(firstrun, thirdrun);
}).timeout(10000);
Expand Down
17 changes: 7 additions & 10 deletions test/testUpCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
const assert = require('assert');
const path = require('path');
const fse = require('fs-extra');
const md5 = require('../src/md5.js');
const {
initGit,
assertHttp,
Expand All @@ -29,14 +28,12 @@ const TEST_DIR = path.resolve('test/integration');
describe('Integration test for up command', () => {
let testDir;
let buildDir;
let welcomeTxtName;

beforeEach(async function before() {
this.timeout(20000);
const testRoot = await createTestRoot();
testDir = path.resolve(testRoot, 'project');
buildDir = path.resolve(testRoot, '.hlx/build');
welcomeTxtName = `welcome.${md5(path.resolve(testDir, 'src/welcome.txt')).slice(-8)}.txt`;
await fse.copy(TEST_DIR, testDir);
});

Expand Down Expand Up @@ -94,10 +91,10 @@ describe('Integration test for up command', () => {
.on('started', async () => {
try {
const replacements = [
{ pattern: 'welcome.txt', with: welcomeTxtName },
{ pattern: 'welcome.txt', with: 'welcome.bc53b44e.txt' },
];
await assertHttp(`http://localhost:${cmd.project.server.port}/index.html`, 200, 'simple_response.html', replacements);
await assertHttp(`http://localhost:${cmd.project.server.port}/dist/${welcomeTxtName}`, 200, 'welcome_response.txt');
await assertHttp(`http://localhost:${cmd.project.server.port}/dist/welcome.bc53b44e.txt`, 200, 'welcome_response.txt');
myDone();
} catch (e) {
myDone(e);
Expand Down Expand Up @@ -134,10 +131,10 @@ describe('Integration test for up command', () => {
.on('started', async () => {
try {
const replacements = [
{ pattern: 'welcome.txt', with: welcomeTxtName },
{ pattern: 'welcome.txt', with: 'welcome.bc53b44e.txt' },
];
await assertHttp(`http://localhost:${cmd.project.server.port}/index.html`, 200, 'simple_response.html', replacements);
await assertHttp(`http://localhost:${cmd.project.server.port}/dist/${welcomeTxtName}`, 200, 'welcome_response.txt');
await assertHttp(`http://localhost:${cmd.project.server.port}/dist/welcome.bc53b44e.txt`, 200, 'welcome_response.txt');
await fse.copy(srcFile, dstFile);
} catch (e) {
myDone(e);
Expand Down Expand Up @@ -180,10 +177,10 @@ describe('Integration test for up command', () => {
.on('started', async () => {
try {
const replacements = [
{ pattern: 'welcome.txt', with: welcomeTxtName },
{ pattern: 'welcome.txt', with: 'welcome.bc53b44e.txt' },
];
await assertHttp(`http://localhost:${cmd.project.server.port}/index.html`, 200, 'simple_response.html', replacements);
await assertHttp(`http://localhost:${cmd.project.server.port}/dist/${welcomeTxtName}`, 200, 'welcome_response.txt');
await assertHttp(`http://localhost:${cmd.project.server.port}/dist/welcome.bc53b44e.txt`, 200, 'welcome_response.txt');
await fse.copy(srcFile, dstFile);
} catch (e) {
myDone(e);
Expand All @@ -194,7 +191,7 @@ describe('Integration test for up command', () => {
})
.on('build', async () => {
try {
await assertHttp(`http://localhost:${cmd.project.server.port}/dist/${welcomeTxtName}`, 200, 'welcome_response2.txt');
await assertHttp(`http://localhost:${cmd.project.server.port}/dist/welcome.bc53b44e.txt`, 200, 'welcome_response2.txt');
myDone();
} catch (e) {
myDone(e);
Expand Down
15 changes: 5 additions & 10 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,13 @@ function initGit(dir) {
shell.cd(pwd);
}

async function assertFile(p) {
const exists = await fse.pathExists(p);
if (!exists) {
function assertFile(p, expectMissing) {
const exists = fse.pathExistsSync(p);
if (!exists && !expectMissing) {
assert.fail(`Expected file at ${p} to exists`);
}
}

async function assertFileMissing(p) {
const exists = await fse.pathExists(p);
if (exists) {
assert.fail(`Expected file at ${p} to be missing`);
if (exists && expectMissing) {
assert.fail(`Unexpected file at ${p} exists`);
}
}

Expand Down Expand Up @@ -142,7 +138,6 @@ async function processSource(scriptName) {

module.exports = {
assertFile,
assertFileMissing,
assertHttp,
assertZipEntry,
initGit,
Expand Down

0 comments on commit 6e21820

Please sign in to comment.