Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
176b08c
chore: add info package to webpack-cli
rishabh3112 Apr 2, 2020
b36fa22
chore: sync fork
rishabh3112 Apr 4, 2020
7814a0c
chore: rebase
rishabh3112 Apr 29, 2020
a0fc0dc
chore: typo
rishabh3112 Apr 29, 2020
21a025d
chore: test with multiple entries
rishabh3112 Apr 29, 2020
63af706
Merge branch 'next' into tests/more-init
jamesgeorge007 Apr 29, 2020
652dfd3
chore: add test for css option
rishabh3112 Apr 30, 2020
c4b0016
Merge branch 'tests/more-init' of https://github.com/webpack/webpack-…
rishabh3112 Apr 30, 2020
2d3462f
Merge branch 'next' into tests/more-init
rishabh3112 May 5, 2020
af61ace
Merge branch 'next' into tests/more-init
rishabh3112 May 9, 2020
465944e
chore: add more tests
rishabh3112 May 12, 2020
6537e96
chore: add tests for package json
rishabh3112 May 12, 2020
a19f489
Merge branch 'tests/more-init' of https://github.com/webpack/webpack-…
rishabh3112 May 12, 2020
12cd10d
chore: add more package json tests
rishabh3112 May 12, 2020
698320e
chore: add typescript test
rishabh3112 May 12, 2020
b97f91c
chore: update language name
rishabh3112 May 12, 2020
88cd93a
Merge branch 'next' into tests/more-init
jamesgeorge007 May 12, 2020
6b8264d
chore: reduce timeout by a factor of 2
rishabh3112 May 13, 2020
de0f863
chore: use resolve instead of join
rishabh3112 May 13, 2020
6a91677
Merge branch 'tests/more-init' of https://github.com/webpack/webpack-…
rishabh3112 May 13, 2020
4edfbdc
chore: debug css test
rishabh3112 May 13, 2020
cfe40cd
chore: rebase
rishabh3112 May 13, 2020
87cd37d
chore: fix typo and rerun ci
rishabh3112 May 13, 2020
3b5f3e8
chore: remove logs
rishabh3112 May 13, 2020
bbb75cf
chore: remove check from lock file
rishabh3112 May 13, 2020
51e2497
chore: timeout to 50 sec
rishabh3112 May 13, 2020
dfe8602
chore: increse timeout to 60s
rishabh3112 May 13, 2020
2014ff4
chore: update inquirer test
rishabh3112 May 13, 2020
7a54afe
Merge branch 'next' into tests/more-init
jamesgeorge007 May 13, 2020
bb19844
tests: check for lock file creation and other minor tweaks
jamesgeorge007 May 13, 2020
0a494b6
tests: add debug statements
rishabh3112 May 14, 2020
6851f2d
chore: update test util to wait
rishabh3112 May 14, 2020
ab328a2
chore: update tests
rishabh3112 May 14, 2020
3dc7cd7
chore: fix multiple entries test
rishabh3112 May 14, 2020
fb97df8
chore: debug tests
rishabh3112 May 14, 2020
f6a7a61
chore: debug tests
rishabh3112 May 15, 2020
3e631bd
test: add test for invalid scaffold
rishabh3112 May 15, 2020
4f3a747
chore: debug tests
rishabh3112 May 15, 2020
dd30b42
chore: improve test
rishabh3112 May 15, 2020
3d63bc4
fix: scaffold util
rishabh3112 May 15, 2020
6fc57b0
fix: scaffold utility
rishabh3112 May 15, 2020
1cca497
fix: plugin test
rishabh3112 May 15, 2020
9c50dde
chore: remove install dependent checks
rishabh3112 May 19, 2020
212c4e5
chore: fix loader timeout
rishabh3112 May 19, 2020
9ccb8dc
chore: use webpack next
rishabh3112 May 19, 2020
b364a16
chore: add test skip when install error
rishabh3112 May 19, 2020
05c247c
chore: debug
rishabh3112 May 19, 2020
548c012
chore: skip when install fail
rishabh3112 May 19, 2020
9e9aac6
Merge branch 'next' into tests/more-init
rishabh3112 May 19, 2020
093cad7
chore: fix migrate
rishabh3112 May 19, 2020
b3ee745
chore: remove logs
rishabh3112 May 19, 2020
7be458b
chore: remove redundant import
rishabh3112 May 19, 2020
5f51c0e
fix: inquirer test
rishabh3112 May 19, 2020
b34a484
chore: increase timeout for css and ts
rishabh3112 May 20, 2020
bc17c0b
Merge branch 'next' into tests/more-init
rishabh3112 May 20, 2020
07470fe
Merge branch 'next' into tests/more-init
rishabh3112 May 20, 2020
281bd48
chore: fix condition
rishabh3112 May 20, 2020
a26fdb2
chore: update comment
rishabh3112 May 22, 2020
f3488f0
Merge branch 'next' into tests/more-init
rishabh3112 May 22, 2020
818e21c
chore: use webpack latest
rishabh3112 May 23, 2020
d7d5015
Merge branch 'tests/more-init' of https://github.com/webpack/webpack-…
rishabh3112 May 23, 2020
b90229f
Merge branch 'next' into tests/more-init
rishabh3112 May 23, 2020
ef2658f
Merge branch 'next' into tests/more-init
jamesgeorge007 May 23, 2020
94790a9
Merge branch 'next' into tests/more-init
jamesgeorge007 May 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
.idea
.vscode

# IDE files
*.code-workspace

# Vim swap files
.s[a-z][a-z]
.*.s[a-z][a-z]
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Node } from './types/NodePath';
*/

function mapOptionsToTransform(config: Config): string[] {
if (!config.webpackOptions) return [];
return Object.keys(config.webpackOptions).filter((k: string): boolean => PROP_TYPES.has(k));
}

Expand Down
24 changes: 20 additions & 4 deletions test/init/auto/init-auto.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

const fs = require('fs');
const rimraf = require('rimraf');
const { join } = require('path');
const { join, resolve } = require('path');
const { run } = require('../../utils/test-utils');

const firstPrompt = 'Will your application have multiple bundles?';
const genPath = join(__dirname, 'test-assets');

jest.setTimeout(200000);
jest.setTimeout(60000);
describe('init auto flag', () => {
beforeAll(() => {
rimraf.sync(genPath);
Expand All @@ -32,11 +32,27 @@ describe('init auto flag', () => {
expect(stdout).toBeTruthy();
expect(stdout).not.toContain(firstPrompt);

// Skip test in case installation fails
if (!fs.existsSync(resolve(genPath, './yarn.lock'))) {
return;
}

// Test regressively files are scaffolded
const files = ['sw.js', 'package.json', 'src/index.js'];
const files = ['./sw.js', './package.json', './src/index.js'];

// eslint-disable-next-line prettier/prettier
files.forEach((file) => {
expect(fs.existsSync(join(genPath, file))).toBeTruthy();
expect(fs.existsSync(resolve(genPath, file))).toBeTruthy();
});

// Check package json is correctly configured
const pkgJsonTests = () => {
const pkgJson = require(join(genPath, './package.json'));
expect(pkgJson).toBeTruthy();
expect(pkgJson['devDependencies']).toBeTruthy();
expect(pkgJson['devDependencies']['webpack']).toBeTruthy();
expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy();
};
expect(pkgJsonTests).not.toThrow();
});
});
6 changes: 6 additions & 0 deletions test/init/coreFlags/init-flags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ describe('init with core flags', () => {
expect(stdout).not.toContain(firstPrompt);
expect(stdout).toContain('Initialize a new webpack configuration');
});
it('should throw error with invalid scaffolder package', () => {
const { stdout, stderr } = run(__dirname, ['init', 'webpack-rocks'], false);
expect(stdout).toBeFalsy();
expect(stderr).toBeTruthy();
expect(stderr).toContain("[webpack-cli] Promise rejection: TypeError: webpack-rocks isn't a valid name");
});
});
28 changes: 22 additions & 6 deletions test/init/generator/init-inquirer.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

const fs = require('fs');
const path = require('path');
const { join, resolve } = require('path');
const rimraf = require('rimraf');
const { runPromptWithAnswers } = require('../../utils/test-utils');
const firstPrompt = 'Will your application have multiple bundles?';

const ENTER = '\x0D';
const genPath = path.join(__dirname, 'test-assets');
const genPath = join(__dirname, 'test-assets');

jest.setTimeout(200000);
jest.setTimeout(100000);

describe('init', () => {
beforeAll(() => {
Expand All @@ -22,16 +22,32 @@ describe('init', () => {
});

it('should scaffold when given answers', async () => {
const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER]);
const { stdout } = await runPromptWithAnswers(genPath, ['init'], [`N${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER]);

expect(stdout).toBeTruthy();
expect(stdout).toContain(firstPrompt);

// Skip test in case installation fails
if (!fs.existsSync(resolve(genPath, './yarn.lock'))) {
return;
}

// Test regressively files are scaffolded
const files = ['sw.js', 'package.json', 'src/index.js'];
const files = ['./sw.js', './package.json', './src/index.js'];

// eslint-disable-next-line prettier/prettier
files.forEach((file) => {
expect(fs.existsSync(path.join(genPath, file))).toBeTruthy();
expect(fs.existsSync(resolve(genPath, file))).toBeTruthy();
});

// Check package json is correctly configured
const pkgJsonTests = () => {
const pkgJson = require(join(genPath, './package.json'));
expect(pkgJson).toBeTruthy();
expect(pkgJson['devDependencies']).toBeTruthy();
expect(pkgJson['devDependencies']['webpack']).toBeTruthy();
expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy();
};
expect(pkgJsonTests).not.toThrow();
});
});
60 changes: 60 additions & 0 deletions test/init/language/css/init-language-css.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';

const fs = require('fs');
const { join, resolve } = require('path');
const rimraf = require('rimraf');
const { runPromptWithAnswers } = require('../../../utils/test-utils');
const firstPrompt = 'Will your application have multiple bundles?';

const ENTER = '\x0D';
const DOWN = '\x1B\x5B\x42';
const genPath = join(__dirname, 'test-assets');

jest.setTimeout(100000);

describe('init with SCSS', () => {
beforeAll(() => {
rimraf.sync(genPath);
fs.mkdirSync(genPath);
});

afterAll(() => {
rimraf.sync(genPath);
});

it('should use SCSS', async () => {
const { stdout } = await runPromptWithAnswers(
genPath,
['init'],
[`N${ENTER}`, ENTER, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, `Y${ENTER}`, `apple${ENTER}`],
);

expect(stdout).toBeTruthy();
expect(stdout).toContain(firstPrompt);

// Skip test in case installation fails
if (!fs.existsSync(resolve(genPath, './yarn.lock'))) {
return;
}

// Test regressively files are scaffolded
const files = ['./package.json', './.yo-rc.json', './src/index.js'];

// eslint-disable-next-line prettier/prettier
files.forEach((file) => {
expect(fs.existsSync(resolve(genPath, file))).toBeTruthy();
});

// Check if package.json is correctly configured
const pkgJsonTests = () => {
const pkgJson = require(join(genPath, './package.json'));
expect(pkgJson).toBeTruthy();
expect(pkgJson['devDependencies']).toBeTruthy();
expect(pkgJson['devDependencies']['webpack']).toBeTruthy();
expect(pkgJson['devDependencies']['node-sass']).toBeTruthy();
expect(pkgJson['devDependencies']['mini-css-extract-plugin']).toBeTruthy();
expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy();
};
expect(pkgJsonTests).not.toThrow();
});
});
60 changes: 60 additions & 0 deletions test/init/language/js/init-language-js.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';

const fs = require('fs');
const { join, resolve } = require('path');
const rimraf = require('rimraf');
const { runPromptWithAnswers } = require('../../../utils/test-utils');
const firstPrompt = 'Will your application have multiple bundles?';

const ENTER = '\x0D';
const DOWN = '\x1B\x5B\x42';
const genPath = join(__dirname, 'test-assets');

jest.setTimeout(100000);

describe('init with Typescript', () => {
beforeAll(() => {
rimraf.sync(genPath);
fs.mkdirSync(genPath);
});

afterAll(() => {
rimraf.sync(genPath);
});

it('should use typescript', async () => {
const { stdout } = await runPromptWithAnswers(
genPath,
['init'],
[`N${ENTER}`, ENTER, ENTER, `${DOWN}${DOWN}${ENTER}`, ENTER, ENTER],
);

expect(stdout).toBeTruthy();
expect(stdout).toContain(firstPrompt);

// Skip test in case installation fails
if (!fs.existsSync(resolve(genPath, './yarn.lock'))) {
return;
}

// Test regressively files are scaffolded
const files = ['./package.json', './.yo-rc.json', './tsconfig.json', './src/index.ts'];

// eslint-disable-next-line prettier/prettier
files.forEach((file) => {
expect(fs.existsSync(resolve(genPath, file))).toBeTruthy();
});

// Check package json is correctly configured
const pkgJsonTests = () => {
const pkgJson = require(join(genPath, './package.json'));
expect(pkgJson).toBeTruthy();
expect(pkgJson['devDependencies']).toBeTruthy();
expect(pkgJson['devDependencies']['webpack']).toBeTruthy();
expect(pkgJson['devDependencies']['typescript']).toBeTruthy();
expect(pkgJson['devDependencies']['ts-loader']).toBeTruthy();
expect(pkgJson['scripts']['build'] == 'webpack').toBeTruthy();
};
expect(pkgJsonTests).not.toThrow();
});
});
46 changes: 46 additions & 0 deletions test/init/multipleEntries/init-multipleEntries.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';

const fs = require('fs');
const path = require('path');
const rimraf = require('rimraf');
const { runPromptWithAnswers } = require('../../utils/test-utils');
const firstPrompt = 'Will your application have multiple bundles?';

const ENTER = '\x0D';
const genPath = path.join(__dirname, 'test-assets');

jest.setTimeout(100000);

describe('init with multiple entries', () => {
beforeAll(() => {
rimraf.sync(genPath);
fs.mkdirSync(genPath);
});

afterAll(() => {
rimraf.sync(genPath);
});

it('should scaffold with multiple entries', async () => {
const { stdout } = await runPromptWithAnswers(
genPath,
['init'],
[`Y${ENTER}`, `a, b${ENTER}`, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER],
);

expect(stdout).toBeTruthy();
expect(stdout).toContain(firstPrompt);

// Skip test in case installation fails
if (!fs.existsSync(path.resolve(genPath, './yarn.lock'))) {
return;
}

// Test regressively files are scaffolded
const files = ['./package.json', './src/a.js', './src/b.js', './.yo-rc.json'];
// eslint-disable-next-line prettier/prettier
files.forEach((file) => {
expect(fs.existsSync(path.resolve(genPath, file))).toBeTruthy();
});
});
});
10 changes: 8 additions & 2 deletions test/loader/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const { existsSync } = require('fs');
const { join } = require('path');
const { join, resolve } = require('path');
const rimraf = require('rimraf');
const { run, runPromptWithAnswers } = require('../utils/test-utils');

Expand All @@ -12,7 +12,8 @@ const loaderName = 'test-loader';
const loaderPath = join(__dirname, loaderName);

// Since scaffolding is time consuming
jest.setTimeout(40000);

jest.setTimeout(60000);

describe('loader command', () => {
beforeAll(() => {
Expand All @@ -35,6 +36,11 @@ describe('loader command', () => {

expect(stdout).toContain(firstPrompt);

// Skip test in case installation fails
if (!existsSync(resolve(loaderPath, './yarn.lock'))) {
return;
}

// check if the output directory exists with the appropriate loader name
expect(existsSync(join(__dirname, loaderName))).toBeTruthy();

Expand Down
2 changes: 2 additions & 0 deletions test/migrate/config/migrate-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const outputPath = path.join(__dirname, outputDir);
const outputFile = `${outputDir}/updated-webpack.config.js`;
const outputFilePath = path.join(__dirname, outputFile);

jest.setTimeout(60000);

describe('migrate command', () => {
beforeEach(() => {
rimraf.sync(outputPath);
Expand Down
9 changes: 7 additions & 2 deletions test/plugin/plugin.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { existsSync } = require('fs');
const { join } = require('path');
const { join, resolve } = require('path');
const rimraf = require('rimraf');
const { run, runPromptWithAnswers } = require('../utils/test-utils');

Expand All @@ -9,7 +9,7 @@ const pluginName = 'test-plugin';
const pluginPath = join(__dirname, pluginName);

// Since scaffolding is time consuming
jest.setTimeout(40000);
jest.setTimeout(60000);

describe('plugin command', () => {
beforeAll(() => {
Expand All @@ -35,6 +35,11 @@ describe('plugin command', () => {
// check if the output directory exists with the appropriate plugin name
expect(existsSync(join(__dirname, pluginName))).toBeTruthy();

// Skip test in case installation fails
if (!existsSync(resolve(pluginPath, './yarn.lock'))) {
return;
}

// Test regressively files are scaffolded
const files = ['package.json', 'examples', 'src', 'test', 'src/index.js', 'examples/simple/webpack.config.js'];

Expand Down