Skip to content

Commit

Permalink
feat(cli): remove --minify and --cache
Browse files Browse the repository at this point in the history
fixes #986
  • Loading branch information
tripodsan committed Jun 12, 2019
1 parent 48b07cb commit b598041
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 113 deletions.
16 changes: 2 additions & 14 deletions src/build.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const AbstractCommand = require('./abstract.cmd.js');
class BuildCommand extends AbstractCommand {
constructor(logger) {
super(logger);
this._cache = null;
this._minify = false;
this._target = null;
this._files = null;
}
Expand All @@ -32,16 +30,6 @@ class BuildCommand extends AbstractCommand {
return false;
}

withCacheEnabled(cache) {
this._cache = cache;
return this;
}

withMinifyEnabled(target) {
this._minify = target;
return this;
}

withTargetDir(target) {
this._target = target;
return this;
Expand Down Expand Up @@ -69,8 +57,8 @@ class BuildCommand extends AbstractCommand {
logLevel: 3,
detailedReport: true,
watch: false,
cache: this._cache,
minify: this._minify,
cache: false,
minify: false,
outDir: this._target,
killWorkers: true,
};
Expand Down
2 changes: 0 additions & 2 deletions src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ module.exports = function build() {
}

await executor
.withCacheEnabled(argv.cache)
.withMinifyEnabled(argv.minify)
.withTargetDir(argv.target)
.withFiles(argv.files)
.run();
Expand Down
2 changes: 0 additions & 2 deletions src/up.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ module.exports = function up() {
}

await executor
.withCacheEnabled(argv.cache)
.withMinifyEnabled(argv.minify)
.withTargetDir(argv.target)
.withFiles(argv.files)
.withOverrideHost(argv.host)
Expand Down
10 changes: 0 additions & 10 deletions src/yargs-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ module.exports = function commonArgs(yargs) {
default: '.hlx/build',
describe: 'Target directory for compiled JS',
})
.option('cache', {
describe: 'Enable or disable compile cache',
boolean: true,
default: false,
})
.option('minify', {
describe: 'Minify JS',
boolean: true,
default: false,
})
.positional('files', {
describe: 'The template files to compile',
default: ['src/**/*.htl', 'src/**/*.js', 'src/**/*.jsx', 'cgi-bin/**/*.js'],
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/all.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ HLX_LOG_FILE = test.log
HLX_TARGET = foo

# build + up
HLX_CACHE = true
HLX_MINIFY = true
HLX_FILES = *.htl,*.js

# up
Expand Down
34 changes: 2 additions & 32 deletions test/testBuildCli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ describe('hlx build', () => {
beforeEach(() => {
clearHelixEnv();
mockBuild = sinon.createStubInstance(BuildCommand);
mockBuild.withCacheEnabled.returnsThis();
mockBuild.withMinifyEnabled.returnsThis();
mockBuild.withTargetDir.returnsThis();
mockBuild.withFiles.returnsThis();
mockBuild.run.returnsThis();
Expand All @@ -43,8 +41,6 @@ describe('hlx build', () => {
new CLI()
.withCommandExecutor('build', mockBuild)
.run(['build']);
sinon.assert.calledWith(mockBuild.withCacheEnabled, false);
sinon.assert.calledWith(mockBuild.withMinifyEnabled, false);
sinon.assert.calledWith(mockBuild.withTargetDir, '.hlx/build');
sinon.assert.calledWith(mockBuild.withFiles, ['src/**/*.htl', 'src/**/*.js', 'src/**/*.jsx', 'cgi-bin/**/*.js']);
sinon.assert.calledOnce(mockBuild.run);
Expand All @@ -55,37 +51,11 @@ describe('hlx build', () => {
new CLI()
.withCommandExecutor('build', mockBuild)
.run(['build']);
sinon.assert.calledWith(mockBuild.withCacheEnabled, true);
sinon.assert.calledWith(mockBuild.withMinifyEnabled, true);
sinon.assert.calledWith(mockBuild.withTargetDir, 'foo');
sinon.assert.calledWith(mockBuild.withFiles, ['*.htl', '*.js']);
sinon.assert.calledOnce(mockBuild.run);
});

it('hlx build can enable cache', () => {
new CLI()
.withCommandExecutor('build', mockBuild)
.run(['build', '--cache']);
sinon.assert.calledWith(mockBuild.withCacheEnabled, true);
sinon.assert.calledOnce(mockBuild.run);
});

it('hlx build can enable cache with value', () => {
new CLI()
.withCommandExecutor('build', mockBuild)
.run(['build', '--cache', 'true']);
sinon.assert.calledWith(mockBuild.withCacheEnabled, true);
sinon.assert.calledOnce(mockBuild.run);
});

it('hlx build can enable minify', () => {
new CLI()
.withCommandExecutor('build', mockBuild)
.run(['build', '--minify']);
sinon.assert.calledWith(mockBuild.withMinifyEnabled, true);
sinon.assert.calledOnce(mockBuild.run);
});

it('hlx build can set target', () => {
new CLI()
.withCommandExecutor('build', mockBuild)
Expand Down Expand Up @@ -121,9 +91,9 @@ describe('hlx build', () => {
it('hlx build can set specify files without option and additional args', () => {
new CLI()
.withCommandExecutor('build', mockBuild)
.run(['build', 'lib/*.htl', 'index.htl', '--no-cache']);
.run(['build', 'lib/*.htl', 'index.htl', '--target', 'foo']);
sinon.assert.calledWith(mockBuild.withFiles, ['lib/*.htl', 'index.htl']);
sinon.assert.calledWith(mockBuild.withCacheEnabled, false);
sinon.assert.calledWith(mockBuild.withTargetDir, 'foo');
sinon.assert.calledOnce(mockBuild.run);
});
});
1 change: 0 additions & 1 deletion test/testBuildCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('Integration test for build', function suite() {
await new BuildCommand()
.withFiles(['test/integration/src/**/*.htl', 'test/integration/src/**/*.js'])
.withTargetDir(buildDir)
.withCacheEnabled(false)
.run();

assertFile(path.resolve(buildDir, 'html.js'));
Expand Down
3 changes: 0 additions & 3 deletions test/testDeployCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ describe('hlx deploy (Integration)', () => {
path.resolve(testRoot, 'src/third_helper.js'),
])
.withTargetDir(buildDir)
.withCacheEnabled(false)
.run();

const cmd = await new DeployCommand(logger)
Expand Down Expand Up @@ -398,7 +397,6 @@ describe('hlx deploy (Integration)', () => {
path.resolve(testRoot, 'cgi-bin/hello.js'),
])
.withTargetDir(buildDir)
.withCacheEnabled(false)
.run();

const cmd = await new DeployCommand(logger)
Expand Down Expand Up @@ -441,7 +439,6 @@ describe('hlx deploy (Integration)', () => {
path.resolve(testRoot, 'src/third_helper.js'),
])
.withTargetDir(buildDir)
.withCacheEnabled(false)
.run();

const ref = await GitUtils.getCurrentRevision(testRoot);
Expand Down
3 changes: 0 additions & 3 deletions test/testPackageCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('hlx package (Integration)', () => {
'test/integration/src/third_helper.js',
])
.withTargetDir(buildDir)
.withCacheEnabled(false)
.run();

const created = {};
Expand Down Expand Up @@ -88,7 +87,6 @@ describe('hlx package (Integration)', () => {
'test/integration/src/third_helper.js',
])
.withTargetDir(buildDir)
.withCacheEnabled(false)
.run();

const created = {};
Expand Down Expand Up @@ -125,7 +123,6 @@ describe('hlx package (Integration)', () => {
'test/integration/src/xml.js',
])
.withTargetDir(buildDir)
.withCacheEnabled(false)
.run();

await new PackageCommand()
Expand Down
34 changes: 2 additions & 32 deletions test/testUpCli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ describe('hlx up', () => {
beforeEach(() => {
clearHelixEnv();
mockUp = sinon.createStubInstance(UpCommand);
mockUp.withCacheEnabled.returnsThis();
mockUp.withMinifyEnabled.returnsThis();
mockUp.withTargetDir.returnsThis();
mockUp.withFiles.returnsThis();
mockUp.withOpen.returnsThis();
Expand All @@ -48,8 +46,6 @@ describe('hlx up', () => {
new CLI()
.withCommandExecutor('up', mockUp)
.run(['up']);
sinon.assert.calledWith(mockUp.withCacheEnabled, false);
sinon.assert.calledWith(mockUp.withMinifyEnabled, false);
sinon.assert.calledWith(mockUp.withSaveConfig, false);
sinon.assert.calledWith(mockUp.withTargetDir, '.hlx/build');
sinon.assert.calledWith(mockUp.withFiles, ['src/**/*.htl', 'src/**/*.js', 'src/**/*.jsx', 'cgi-bin/**/*.js']);
Expand All @@ -63,8 +59,6 @@ describe('hlx up', () => {
new CLI()
.withCommandExecutor('up', mockUp)
.run(['up']);
sinon.assert.calledWith(mockUp.withCacheEnabled, true);
sinon.assert.calledWith(mockUp.withMinifyEnabled, true);
sinon.assert.calledWith(mockUp.withTargetDir, 'foo');
sinon.assert.calledWith(mockUp.withFiles, ['*.htl', '*.js']);
sinon.assert.calledWith(mockUp.withOverrideHost, 'www.project-helix.io');
Expand Down Expand Up @@ -99,30 +93,6 @@ describe('hlx up', () => {
sinon.assert.match('HLX_SAVE_CONFIG is not allowed in environment.', failed);
});

it('hlx up can enable cache', () => {
new CLI()
.withCommandExecutor('up', mockUp)
.run(['up', '--cache']);
sinon.assert.calledWith(mockUp.withCacheEnabled, true);
sinon.assert.calledOnce(mockUp.run);
});

it('hlx up can enable cache with value', () => {
new CLI()
.withCommandExecutor('up', mockUp)
.run(['up', '--cache', 'true']);
sinon.assert.calledWith(mockUp.withCacheEnabled, true);
sinon.assert.calledOnce(mockUp.run);
});

it('hlx up can enable minify', () => {
new CLI()
.withCommandExecutor('up', mockUp)
.run(['up', '--minify']);
sinon.assert.calledWith(mockUp.withMinifyEnabled, true);
sinon.assert.calledOnce(mockUp.run);
});

it('hlx up can set target', () => {
new CLI()
.withCommandExecutor('up', mockUp)
Expand Down Expand Up @@ -182,9 +152,9 @@ describe('hlx up', () => {
it('hlx up can set specify files with no --files option and additionals', () => {
new CLI()
.withCommandExecutor('up', mockUp)
.run(['up', 'lib/*.htl', 'index.htl', '--no-cache']);
.run(['up', 'lib/*.htl', 'index.htl', '--target', 'foo']);
sinon.assert.calledWith(mockUp.withFiles, ['lib/*.htl', 'index.htl']);
sinon.assert.calledWith(mockUp.withCacheEnabled, false);
sinon.assert.calledWith(mockUp.withTargetDir, 'foo');
sinon.assert.calledOnce(mockUp.run);
});

Expand Down
10 changes: 0 additions & 10 deletions test/testUpCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ describe('Integration test for up command', function suite() {
it('up command fails outside git repository', async () => {
try {
await new UpCommand()
.withCacheEnabled(false)
.withFiles([path.join(testDir, 'src', '*.htl'), path.join(testDir, 'src', '*.js')])
.withTargetDir(buildDir)
.withDirectory(testDir)
Expand All @@ -82,7 +81,6 @@ describe('Integration test for up command', function suite() {
it('up command succeeds and can be stopped', (done) => {
initGit(testDir, 'https://github.com/adobe/dummy-foo.git');
new UpCommand()
.withCacheEnabled(false)
.withFiles([path.join(testDir, 'src', '*.htl'), path.join(testDir, 'src', '*.js')])
.withTargetDir(buildDir)
.withDirectory(testDir)
Expand All @@ -103,7 +101,6 @@ describe('Integration test for up command', function suite() {
initGit(testDir, 'https://github.com/adobe/dummy-foo.git');
let error = null;
const cmd = new UpCommand()
.withCacheEnabled(false)
.withFiles([
path.join(testDir, 'src', '*.htl'),
path.join(testDir, 'src', '*.js'),
Expand Down Expand Up @@ -139,7 +136,6 @@ describe('Integration test for up command', function suite() {
initGit(testDir, 'https://github.com/adobe/dummy-foo.git');
await fse.rename(path.resolve(testDir, 'default-config.yaml'), path.resolve(testDir, 'helix-config.yaml'));
const cmd = new UpCommand()
.withCacheEnabled(false)
.withFiles([
path.join(testDir, 'src', '*.htl'),
path.join(testDir, 'src', '*.js'),
Expand All @@ -166,7 +162,6 @@ describe('Integration test for up command', function suite() {
initGit(testDir, 'https://github.com/adobe/dummy-foo.git');
await fse.rename(path.resolve(testDir, 'default-config.yaml'), path.resolve(testDir, 'helix-config.yaml'));
const cmd = new UpCommand()
.withCacheEnabled(false)
.withFiles([
path.join(testDir, 'src', '*.htl'),
path.join(testDir, 'src', '*.js'),
Expand Down Expand Up @@ -197,7 +192,6 @@ describe('Integration test for up command', function suite() {
initGit(apiDir, 'https://github.com/adobe/project-helix-api.git');
await fse.rename(path.resolve(testDir, 'default-config.yaml'), path.resolve(testDir, 'helix-config.yaml'));
const cmd = new UpCommand()
.withCacheEnabled(false)
.withFiles([
path.join(testDir, 'src', '*.htl'),
path.join(testDir, 'src', '*.js'),
Expand Down Expand Up @@ -227,7 +221,6 @@ describe('Integration test for up command', function suite() {
const cfg = path.resolve(testDir, 'helix-config.yaml');
await fse.copy(path.resolve(__dirname, 'fixtures', 'default-proxy.yaml'), cfg);
const cmd = new UpCommand()
.withCacheEnabled(false)
.withFiles([path.join(testDir, 'src', '*.htl'), path.join(testDir, 'src', '*.js')])
.withTargetDir(buildDir)
.withDirectory(testDir)
Expand All @@ -251,7 +244,6 @@ describe('Integration test for up command', function suite() {
assertFile(path.resolve(testDir, 'helix-config.yaml'), true);
let error = null;
const cmd = new UpCommand()
.withCacheEnabled(false)
.withFiles([path.join(testDir, 'src', '*.htl'), path.join(testDir, 'src', '*.js')])
.withTargetDir(buildDir)
.withDirectory(testDir)
Expand Down Expand Up @@ -287,7 +279,6 @@ describe('Integration test for up command', function suite() {
initGit(testDir, 'https://github.com/adobe/dummy-foo.git');
let error = null;
const cmd = new UpCommand()
.withCacheEnabled(false)
.withFiles([
path.join(testDir, 'src', '*.htl'),
path.join(testDir, 'src', '*.js'),
Expand Down Expand Up @@ -338,7 +329,6 @@ describe('Integration test for up command', function suite() {
initGit(testDir, 'https://github.com/adobe/dummy-foo.git');
let error = null;
const cmd = new UpCommand()
.withCacheEnabled(false)
.withFiles([
path.join(testDir, 'src', '*.htl'),
path.join(testDir, 'src', '*.js'),
Expand Down
1 change: 0 additions & 1 deletion test/testUpCmdPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('Integration test for up command with helix pages', function suite() {
initGit(testDir, 'https://github.com/adobe/dummy-foo.git');
let error = null;
const cmd = new UpCommand()
.withCacheEnabled(false)
.withTargetDir(buildDir)
.withDirectory(testDir)
.withHelixPagesRepo(helixPagesRepo)
Expand Down
1 change: 0 additions & 1 deletion test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ async function processSource(scriptName, type = 'htl') {
await new BuildCommand()
.withFiles(files)
.withTargetDir(buildDir)
.withCacheEnabled(false)
.run();

return {
Expand Down

0 comments on commit b598041

Please sign in to comment.