From 788bcd724c906e177b50d48f1f36f3bc87878edd Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Thu, 9 Jun 2016 23:56:00 +1000 Subject: [PATCH 01/11] feat: add output path default to schema allow outputPath as a default value in angular-cli.js for all commands to use. Allows for a consistent way to specify where commands should output artefacts or look for them. --- lib/config/schema.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/config/schema.json b/lib/config/schema.json index d8598052dd14..c924bc0de5dc 100644 --- a/lib/config/schema.json +++ b/lib/config/schema.json @@ -95,6 +95,9 @@ }, "lazyRoutePrefix": { "type": "string" + }, + "outputPath": { + "type": "string" } }, "additionalProperties": false From 1c9452070f7c4ba7924cb351ebe73aecce3bd93a Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Fri, 17 Jun 2016 00:33:31 +1000 Subject: [PATCH 02/11] feat: add command utilities add utility functions for commands --- addon/ng2/utilities/command-helper.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 addon/ng2/utilities/command-helper.ts diff --git a/addon/ng2/utilities/command-helper.ts b/addon/ng2/utilities/command-helper.ts new file mode 100644 index 000000000000..09e82bb4528f --- /dev/null +++ b/addon/ng2/utilities/command-helper.ts @@ -0,0 +1,16 @@ +import * as config from '../models/config' + +export function loadDefaults(command) { + command.project.ngConfig = command.project.ngConfig || config.CliConfig.fromProject(); + + let defaultSettings = command.project.ngConfig.defaults || {}; + + let commandOptions = command.availableOptions.map(option => option.key); + + commandOptions.forEach(key => { + // only load defaults that are relevant to the command + if (defaultSettings[key]) { + command.settings[key] = defaultSettings[key]; + } + }); +} From b3e2693b838e95012dec14027856f32e142ca0db Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Wed, 15 Jun 2016 00:41:17 +1000 Subject: [PATCH 03/11] feat: add output path flag to test command add output path flag to test command, allowing default to be overridden. --- addon/ng2/commands/test.js | 13 +++++--- tests/e2e/e2e_workflow.spec.js | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/addon/ng2/commands/test.js b/addon/ng2/commands/test.js index a171d0399722..73cdbf80a5b0 100644 --- a/addon/ng2/commands/test.js +++ b/addon/ng2/commands/test.js @@ -7,7 +7,7 @@ var BuildTask = require('ember-cli/lib/tasks/build'); var BuildWatchTask = require('ember-cli/lib/tasks/build-watch'); const config = require('../models/config'); var TestTask = require('../tasks/test'); - +var CommandHelper = require('../utilities/command-helper'); module.exports = TestCommand.extend({ availableOptions: [ @@ -17,12 +17,17 @@ module.exports = TestCommand.extend({ { name: 'log-level', type: String }, { name: 'port', type: Number }, { name: 'reporters', type: String }, - { name: 'build', type: Boolean, default: true } + { name: 'build', type: Boolean, default: true }, + { name: 'output-path', type: String, default: 'dist/', aliases: ['o'] } ], + beforeRun: function() { + CommandHelper.loadDefaults(this); + }, + run: function (commandOptions) { this.project.ngConfig = this.project.ngConfig || config.CliConfig.fromProject(); - + var buildWatchTask = new BuildWatchTask({ ui: this.ui, @@ -42,7 +47,7 @@ module.exports = TestCommand.extend({ var buildOptions = { environment: 'development', - outputPath: 'dist/' + outputPath: commandOptions.outputPath }; // If not building, mock/suppress build tasks. diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index 3c90073b84fe..82f99ccaeec8 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -282,6 +282,65 @@ describe('Basic end-to-end Workflow', function () { }); }); + it('Can set the default output path', function () { + this.timeout(10000); + + const customOutputPath = 'not-dist/'; + const distFolder = path.join(process.cwd(), customOutputPath); + + var setArgs = [ + 'set', + 'defaults.outputPath', + customOutputPath + ]; + + return ng(setArgs).then(() => { + const indexHtml = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); + expect(indexHtml).to.include('"outputPath": "'+customOutputPath+'"'); + }) + .catch(err => { + throw new Error(err) + }); + }); + + it('`ng test` will build files in outputPath when default is set', function () { + this.timeout(420000); + + const customOutputPath = 'not-dist/'; + const tmpFileLocation = path.join(process.cwd(), customOutputPath, 'test.abc'); + + return ng(testArgs).then(result => { + const exitCode = typeof result === 'object' ? result.exitCode : result; + expect(exitCode).to.be.equal(0); + }).then(() => { + expect(existsSync(tmpFileLocation)).to.be.equal(true); + }) + .catch(err => { + throw new Error(err) + }) + }); + + it('`ng test` will build files in `other-dist/` when output-path flag is used', function () { + this.timeout(420000); + + const customOutputPath = 'other-dist/'; + const tmpFileLocation = path.join(process.cwd(), customOutputPath, 'test.abc'); + + testArgs.push('--output-path'); + testArgs.push(customOutputPath); + + return ng(testArgs).then(result => { + const exitCode = typeof result === 'object' ? result.exitCode : result; + expect(exitCode).to.be.equal(0); + }).then(() => { + expect(existsSync(tmpFileLocation)).to.be.equal(true); + }) + .catch(err => { + throw new Error(err) + }) + }); + + it.skip('Installs sass support successfully', function() { this.timeout(420000); From b11f98c735921d7d45654ab7a4fe1b2527ed7e35 Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Thu, 16 Jun 2016 01:15:31 +1000 Subject: [PATCH 04/11] feat: add build command add build command to replace default build command to allow for output path default. --- addon/ng2/commands/build.ts | 12 ++++++++++++ addon/ng2/index.js | 1 + addon/ng2/utilities/completion.sh | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 addon/ng2/commands/build.ts diff --git a/addon/ng2/commands/build.ts b/addon/ng2/commands/build.ts new file mode 100644 index 000000000000..c5ba83e709ff --- /dev/null +++ b/addon/ng2/commands/build.ts @@ -0,0 +1,12 @@ +import * as CommandHelper from '../utilities/command-helper'; +import * as BuildCommand from 'ember-cli/lib/commands/build'; + +module.exports = BuildCommand.extend({ + + beforeRun: function() { + CommandHelper.loadDefaults(this); + }, + +}); + +module.exports.overrideCore = true; diff --git a/addon/ng2/index.js b/addon/ng2/index.js index cb5a3b548acc..792e39abc499 100644 --- a/addon/ng2/index.js +++ b/addon/ng2/index.js @@ -22,6 +22,7 @@ module.exports = { 'completion': require('./commands/completion'), 'doc': require('./commands/doc'), 'github-pages-deploy': require('./commands/github-pages-deploy'), + 'build': require('./commands/build'), // Easter eggs. 'make-this-awesome': require('./commands/easter-egg')('make-this-awesome'), diff --git a/addon/ng2/utilities/completion.sh b/addon/ng2/utilities/completion.sh index ebb5227cd06b..22db44348dcc 100644 --- a/addon/ng2/utilities/completion.sh +++ b/addon/ng2/utilities/completion.sh @@ -12,7 +12,7 @@ build_opts='--environment --output-path --watch --watcher' serve_opts='--port --host --proxy --insecure-proxy --watcher --live-reload --live-reload-host --live-reload-port --environment --output-path --ssl --ssl-key --ssl-cert' generate_opts='component directive pipe route service' -test_opts='--watch --browsers --colors --log-level --port --reporters' +test_opts='--watch --browsers --colors --log-level --port --reporters --output-path' if type complete &>/dev/null; then _ng_completion() { From 5896408c4651ed4959e52568c231292cf616be9e Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Thu, 16 Jun 2016 07:51:38 +1000 Subject: [PATCH 05/11] feat: add serve command add serve command to replace default serve command to allow for output path default. --- addon/ng2/commands/serve.ts | 12 ++++++++++++ addon/ng2/index.js | 1 + 2 files changed, 13 insertions(+) create mode 100644 addon/ng2/commands/serve.ts diff --git a/addon/ng2/commands/serve.ts b/addon/ng2/commands/serve.ts new file mode 100644 index 000000000000..ac575eb1fb56 --- /dev/null +++ b/addon/ng2/commands/serve.ts @@ -0,0 +1,12 @@ +import * as CommandHelper from '../utilities/command-helper'; +import * as ServeCommand from 'ember-cli/lib/commands/serve'; + +module.exports = ServeCommand.extend({ + + beforeRun: function() { + CommandHelper.loadDefaults(this); + }, + +}); + +module.exports.overrideCore = true; diff --git a/addon/ng2/index.js b/addon/ng2/index.js index 792e39abc499..fa70606a30a3 100644 --- a/addon/ng2/index.js +++ b/addon/ng2/index.js @@ -23,6 +23,7 @@ module.exports = { 'doc': require('./commands/doc'), 'github-pages-deploy': require('./commands/github-pages-deploy'), 'build': require('./commands/build'), + 'serve': require('./commands/serve'), // Easter eggs. 'make-this-awesome': require('./commands/easter-egg')('make-this-awesome'), From 64bcd6c1a84212f48d26bdd72db0fa64b0c647f0 Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Fri, 17 Jun 2016 01:15:15 +1000 Subject: [PATCH 06/11] feat: add output path flag to deploy command add output path flag to deploy command, allowing default to be overridden. --- addon/ng2/commands/github-pages-deploy.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/addon/ng2/commands/github-pages-deploy.ts b/addon/ng2/commands/github-pages-deploy.ts index 8ac1478c1e6f..696be497fbab 100644 --- a/addon/ng2/commands/github-pages-deploy.ts +++ b/addon/ng2/commands/github-pages-deploy.ts @@ -9,6 +9,7 @@ import * as path from 'path'; import * as BuildTask from 'ember-cli/lib/tasks/build'; import * as win from 'ember-cli/lib/utilities/windows-admin'; import * as CreateGithubRepo from '../tasks/create-github-repo'; +import * as CommandHelper from '../utilities/command-helper'; const fsReadFile = Promise.denodeify(fs.readFile); const fsWriteFile = Promise.denodeify(fs.writeFile); @@ -52,8 +53,16 @@ module.exports = Command.extend({ type: String, default: '', description: 'Github username' + }, { + name: 'output-path', + type: String, + default: 'dist/', }], + beforeRun: function() { + CommandHelper.loadDefaults(this); + }, + run: function(options, rawArgs) { var ui = this.ui; var root = this.project.root; @@ -77,7 +86,7 @@ module.exports = Command.extend({ var buildOptions = { environment: options.environment, - outputPath: 'dist/' + outputPath: options.outputPath }; var createGithubRepoTask = new CreateGithubRepo({ @@ -97,7 +106,7 @@ module.exports = Command.extend({ .then(saveStartingBranchName) .then(createGitHubRepoIfNeeded) .then(checkoutGhPages) - .then(copyFiles) + .then(() => copyFiles(options.outputPath)) .then(updateBaseHref) .then(addAndCommit) .then(returnStartingBranch) @@ -156,14 +165,14 @@ module.exports = Command.extend({ .then(() => execPromise(`git commit -m \"initial ${ghPagesBranch} commit\"`)); } - function copyFiles() { - return fsReadDir('dist') + function copyFiles(outputPath) { + return fsReadDir(outputPath) .then((files) => Promise.all(files.map((file) => { if (file === '.gitignore'){ // don't overwrite the .gitignore file return Promise.resolve(); } - return fsCopy(path.join('dist', file), path.join('.', file)) + return fsCopy(path.join(outputPath, file), path.join('.', file)) }))); } From fdb685c0128789a57739b67222267d3cdcf881e3 Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Fri, 17 Jun 2016 02:37:17 +1000 Subject: [PATCH 07/11] feat: add output path flag to init and new commands add output path flag to init and new command, allowing a default output-path to be set on initialising a project --- .../ng2/blueprints/ng2/files/angular-cli.json | 3 ++- addon/ng2/blueprints/ng2/index.js | 3 ++- addon/ng2/commands/init.js | 6 ++++-- addon/ng2/commands/new.ts | 1 + addon/ng2/utilities/completion.sh | 4 ++-- tests/acceptance/init.spec.js | 21 ++++++++++++++++++- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/addon/ng2/blueprints/ng2/files/angular-cli.json b/addon/ng2/blueprints/ng2/files/angular-cli.json index 5b96ba0ba88c..518f71e2de1e 100644 --- a/addon/ng2/blueprints/ng2/files/angular-cli.json +++ b/addon/ng2/blueprints/ng2/files/angular-cli.json @@ -27,6 +27,7 @@ "sourceDir": "<%= sourceDir %>", "styleExt": "<%= styleExt %>", "prefixInterfaces": false, - "lazyRoutePrefix": "+" + "lazyRoutePrefix": "+", + "outputPath": "<%= outputPath %>" } } diff --git a/addon/ng2/blueprints/ng2/index.js b/addon/ng2/blueprints/ng2/index.js index 827a95b443e0..eb9e868e452a 100644 --- a/addon/ng2/blueprints/ng2/index.js +++ b/addon/ng2/blueprints/ng2/index.js @@ -51,7 +51,8 @@ module.exports = { styleExt: this.styleExt, refToTypings: refToTypings, isMobile: options.mobile, - stylePackage: stylePackage + stylePackage: stylePackage, + outputPath: options.outputPath }; }, diff --git a/addon/ng2/commands/init.js b/addon/ng2/commands/init.js index f77a1c2852b7..88729f825ba6 100644 --- a/addon/ng2/commands/init.js +++ b/addon/ng2/commands/init.js @@ -25,7 +25,8 @@ module.exports = Command.extend({ { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, - { name: 'mobile', type: Boolean, default: false } + { name: 'mobile', type: Boolean, default: false }, + { name: 'output-path', type: String, default: 'dist/', aliases: ['o'] }, ], anonymousOptions: [''], @@ -103,7 +104,8 @@ module.exports = Command.extend({ sourceDir: commandOptions.sourceDir, style: commandOptions.style, prefix: commandOptions.prefix, - mobile: commandOptions.mobile + mobile: commandOptions.mobile, + outputPath: commandOptions.outputPath }; if (!validProjectName(packageName)) { diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index 685e4e3e1124..bd95cd329e1d 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -25,6 +25,7 @@ const NewCommand = Command.extend({ { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'mobile', type: Boolean, default: false } + { name: 'output-path', type: String, default: 'dist/', aliases: ['o'] }, ], run: function (commandOptions, rawArgs) { diff --git a/addon/ng2/utilities/completion.sh b/addon/ng2/utilities/completion.sh index 22db44348dcc..1249d8449d30 100644 --- a/addon/ng2/utilities/completion.sh +++ b/addon/ng2/utilities/completion.sh @@ -6,8 +6,8 @@ # ng_opts='new init build serve generate autocomplete e2e lint test version' -init_opts='--dry-run --verbose --blueprint --skip-npm --skip-bower --name' -new_opts='--dry-run --verbose --blueprint --skip-npm --skip-bower --skip-git --directory' +init_opts='--dry-run --verbose --blueprint --skip-npm --skip-bower --name --output-path' +new_opts='--dry-run --verbose --blueprint --skip-npm --skip-bower --skip-git --directory --output-path' build_opts='--environment --output-path --watch --watcher' serve_opts='--port --host --proxy --insecure-proxy --watcher --live-reload --live-reload-host --live-reload-port --environment --output-path --ssl --ssl-key --ssl-cert' diff --git a/tests/acceptance/init.spec.js b/tests/acceptance/init.spec.js index f6d7f07f4801..9b1295bdef79 100644 --- a/tests/acceptance/init.spec.js +++ b/tests/acceptance/init.spec.js @@ -17,6 +17,7 @@ var unique = require('lodash/uniq'); var forEach = require('lodash/forEach'); var any = require('lodash/some'); var EOL = require('os').EOL; +var fs = require('fs'); var defaultIgnoredFiles = Blueprint.ignoredFiles; @@ -108,7 +109,10 @@ describe('Acceptance: ng init', function () { 'init', '--skip-npm', '--skip-bower' - ]).then(confirmBlueprinted); + ]).then(confirmBlueprinted).then(() => { + const indexHtml = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); + expect(indexHtml).to.include('"outputPath": "dist/"'); + }); }); it('ng init --mobile', () => { @@ -200,4 +204,19 @@ describe('Acceptance: ng init', function () { }) .then(confirmBlueprinted); }); + + it('ng init --output-path not-dist/', function () { + var customOutputPath = 'not-dist/' + return ng([ + 'init', + '--skip-npm', + '--skip-bower', + '--output-path', + customOutputPath + ]).then(confirmBlueprinted) + .then(() => { + const settings = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); + expect(settings).to.include('"outputPath": "'+customOutputPath+'"'); + }); + }); }); From 86fb2b70e7566c1c72662e52cde7bf4ac9e8f1a0 Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Fri, 17 Jun 2016 15:29:58 +1000 Subject: [PATCH 08/11] feedback changes for custom output path support --- addon/ng2/commands/github-pages-deploy.ts | 6 +----- addon/ng2/commands/init.js | 4 ++-- addon/ng2/commands/test.js | 9 ++++----- addon/ng2/utilities/command-helper.ts | 13 ++++++++++--- addon/ng2/utilities/completion.sh | 6 +++--- tests/acceptance/init.spec.js | 12 ++++++------ tests/e2e/e2e_workflow.spec.js | 11 +++++------ 7 files changed, 31 insertions(+), 30 deletions(-) diff --git a/addon/ng2/commands/github-pages-deploy.ts b/addon/ng2/commands/github-pages-deploy.ts index 696be497fbab..47bee3168862 100644 --- a/addon/ng2/commands/github-pages-deploy.ts +++ b/addon/ng2/commands/github-pages-deploy.ts @@ -53,13 +53,9 @@ module.exports = Command.extend({ type: String, default: '', description: 'Github username' - }, { - name: 'output-path', - type: String, - default: 'dist/', }], - beforeRun: function() { + beforeRun: function() { CommandHelper.loadDefaults(this); }, diff --git a/addon/ng2/commands/init.js b/addon/ng2/commands/init.js index 88729f825ba6..116d57536af7 100644 --- a/addon/ng2/commands/init.js +++ b/addon/ng2/commands/init.js @@ -26,7 +26,7 @@ module.exports = Command.extend({ { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'mobile', type: Boolean, default: false }, - { name: 'output-path', type: String, default: 'dist/', aliases: ['o'] }, + { name: 'output-path', type: String, default: 'dist/', aliases: ['o'] } ], anonymousOptions: [''], @@ -94,7 +94,7 @@ module.exports = Command.extend({ return Promise.reject(new SilentError(message)); } - + var blueprintOpts = { dryRun: commandOptions.dryRun, blueprint: commandOptions.blueprint || this._defaultBlueprint(), diff --git a/addon/ng2/commands/test.js b/addon/ng2/commands/test.js index 73cdbf80a5b0..bbe84fe2ac96 100644 --- a/addon/ng2/commands/test.js +++ b/addon/ng2/commands/test.js @@ -17,8 +17,7 @@ module.exports = TestCommand.extend({ { name: 'log-level', type: String }, { name: 'port', type: Number }, { name: 'reporters', type: String }, - { name: 'build', type: Boolean, default: true }, - { name: 'output-path', type: String, default: 'dist/', aliases: ['o'] } + { name: 'build', type: Boolean, default: true } ], beforeRun: function() { @@ -27,7 +26,7 @@ module.exports = TestCommand.extend({ run: function (commandOptions) { this.project.ngConfig = this.project.ngConfig || config.CliConfig.fromProject(); - + var buildWatchTask = new BuildWatchTask({ ui: this.ui, @@ -49,7 +48,7 @@ module.exports = TestCommand.extend({ environment: 'development', outputPath: commandOptions.outputPath }; - + // If not building, mock/suppress build tasks. if (!commandOptions.build) { buildTask = { @@ -59,7 +58,7 @@ module.exports = TestCommand.extend({ }; buildWatchTask = buildTask; } - + if (commandOptions.watch) { return win.checkWindowsElevation(this.ui) .then( diff --git a/addon/ng2/utilities/command-helper.ts b/addon/ng2/utilities/command-helper.ts index 09e82bb4528f..bd2f5b1c53dc 100644 --- a/addon/ng2/utilities/command-helper.ts +++ b/addon/ng2/utilities/command-helper.ts @@ -1,16 +1,23 @@ import * as config from '../models/config' export function loadDefaults(command) { - command.project.ngConfig = command.project.ngConfig || config.CliConfig.fromProject(); + command.project.ngConfig = command.project.ngConfig || config.CliConfig.fromProject(); let defaultSettings = command.project.ngConfig.defaults || {}; + // output path should always have a default value + // some commands use it but its not an available flag + let outputPathKey = 'outputPath'; + if (!command.settings[outputPathKey]) { + command.settings[outputPathKey] = 'dist/'; + } + let commandOptions = command.availableOptions.map(option => option.key); - commandOptions.forEach(key => { + commandOptions.forEach(key => { // only load defaults that are relevant to the command if (defaultSettings[key]) { command.settings[key] = defaultSettings[key]; } - }); + }); } diff --git a/addon/ng2/utilities/completion.sh b/addon/ng2/utilities/completion.sh index 1249d8449d30..457839bebea7 100644 --- a/addon/ng2/utilities/completion.sh +++ b/addon/ng2/utilities/completion.sh @@ -1,4 +1,4 @@ -###-begin-ng-completion### +###-begin-ng-completion### # # ng command completion script # @@ -12,7 +12,7 @@ build_opts='--environment --output-path --watch --watcher' serve_opts='--port --host --proxy --insecure-proxy --watcher --live-reload --live-reload-host --live-reload-port --environment --output-path --ssl --ssl-key --ssl-cert' generate_opts='component directive pipe route service' -test_opts='--watch --browsers --colors --log-level --port --reporters --output-path' +test_opts='--watch --browsers --colors --log-level --port --reporters' if type complete &>/dev/null; then _ng_completion() { @@ -53,7 +53,7 @@ elif type compctl &>/dev/null; then g|generate) opts=$generate_opts ;; test) opts=$test_opts ;; esac - + setopt shwordsplit reply=($opts) unset shwordsplit diff --git a/tests/acceptance/init.spec.js b/tests/acceptance/init.spec.js index 9b1295bdef79..5a8d749ceac0 100644 --- a/tests/acceptance/init.spec.js +++ b/tests/acceptance/init.spec.js @@ -60,7 +60,7 @@ describe('Acceptance: ng init', function () { expected[index] = expected[index].replace(/__styleext__/g, 'css'); expected[index] = expected[index].replace(/__path__/g, 'src'); }); - + if (isMobile) { expected = expected.filter(p => p.indexOf('tmp.component.html') < 0); expected = expected.filter(p => p.indexOf('tmp.component.css') < 0); @@ -109,9 +109,9 @@ describe('Acceptance: ng init', function () { 'init', '--skip-npm', '--skip-bower' - ]).then(confirmBlueprinted).then(() => { - const indexHtml = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); - expect(indexHtml).to.include('"outputPath": "dist/"'); + ]).then(confirmBlueprinted).then(() => { + const settings = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); + expect(settings).to.include('"outputPath": "dist/"'); }); }); @@ -214,9 +214,9 @@ describe('Acceptance: ng init', function () { '--output-path', customOutputPath ]).then(confirmBlueprinted) - .then(() => { + .then(() => { const settings = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); expect(settings).to.include('"outputPath": "'+customOutputPath+'"'); - }); + }); }); }); diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index 82f99ccaeec8..b3185b3feb77 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -286,17 +286,16 @@ describe('Basic end-to-end Workflow', function () { this.timeout(10000); const customOutputPath = 'not-dist/'; - const distFolder = path.join(process.cwd(), customOutputPath); var setArgs = [ - 'set', + 'set', 'defaults.outputPath', customOutputPath ]; - return ng(setArgs).then(() => { - const indexHtml = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); - expect(indexHtml).to.include('"outputPath": "'+customOutputPath+'"'); + return ng(setArgs).then(() => { + const settings = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); + expect(settings).to.include('"outputPath": "'+customOutputPath+'"'); }) .catch(err => { throw new Error(err) @@ -339,7 +338,7 @@ describe('Basic end-to-end Workflow', function () { throw new Error(err) }) }); - + it.skip('Installs sass support successfully', function() { this.timeout(420000); From c0ecf1a22334a6a0f1fff1af100b078adc2aee03 Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Fri, 17 Jun 2016 16:22:31 +1000 Subject: [PATCH 09/11] remove e2e test not needed after feedback changes --- addon/ng2/utilities/command-helper.ts | 4 ++-- tests/e2e/e2e_workflow.spec.js | 27 ++++----------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/addon/ng2/utilities/command-helper.ts b/addon/ng2/utilities/command-helper.ts index bd2f5b1c53dc..da03167de2a3 100644 --- a/addon/ng2/utilities/command-helper.ts +++ b/addon/ng2/utilities/command-helper.ts @@ -1,4 +1,4 @@ -import * as config from '../models/config' +import * as config from '../models/config'; export function loadDefaults(command) { command.project.ngConfig = command.project.ngConfig || config.CliConfig.fromProject(); @@ -9,7 +9,7 @@ export function loadDefaults(command) { // some commands use it but its not an available flag let outputPathKey = 'outputPath'; if (!command.settings[outputPathKey]) { - command.settings[outputPathKey] = 'dist/'; + command.settings[outputPathKey] = defaultSettings[outputPathKey] || 'dist/'; } let commandOptions = command.availableOptions.map(option => option.key); diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index b3185b3feb77..d4adf09be808 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -305,13 +305,15 @@ describe('Basic end-to-end Workflow', function () { it('`ng test` will build files in outputPath when default is set', function () { this.timeout(420000); - const customOutputPath = 'not-dist/'; - const tmpFileLocation = path.join(process.cwd(), customOutputPath, 'test.abc'); + const tmpFileLocation = path.join(process.cwd(), 'not-dist/', 'test.abc'); return ng(testArgs).then(result => { const exitCode = typeof result === 'object' ? result.exitCode : result; expect(exitCode).to.be.equal(0); }).then(() => { + console.log('--------------------'); + console.log('tmpFileLocation',tmpFileLocation); + console.log('existsSync(tmpFileLocation)',existsSync(tmpFileLocation)); expect(existsSync(tmpFileLocation)).to.be.equal(true); }) .catch(err => { @@ -319,27 +321,6 @@ describe('Basic end-to-end Workflow', function () { }) }); - it('`ng test` will build files in `other-dist/` when output-path flag is used', function () { - this.timeout(420000); - - const customOutputPath = 'other-dist/'; - const tmpFileLocation = path.join(process.cwd(), customOutputPath, 'test.abc'); - - testArgs.push('--output-path'); - testArgs.push(customOutputPath); - - return ng(testArgs).then(result => { - const exitCode = typeof result === 'object' ? result.exitCode : result; - expect(exitCode).to.be.equal(0); - }).then(() => { - expect(existsSync(tmpFileLocation)).to.be.equal(true); - }) - .catch(err => { - throw new Error(err) - }) - }); - - it.skip('Installs sass support successfully', function() { this.timeout(420000); From 867185ec7da2a5967b1828a7e4480887234c1472 Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Fri, 17 Jun 2016 19:30:46 +1000 Subject: [PATCH 10/11] remove console debug --- tests/e2e/e2e_workflow.spec.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index d4adf09be808..beee70a2e2a7 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -311,9 +311,6 @@ describe('Basic end-to-end Workflow', function () { const exitCode = typeof result === 'object' ? result.exitCode : result; expect(exitCode).to.be.equal(0); }).then(() => { - console.log('--------------------'); - console.log('tmpFileLocation',tmpFileLocation); - console.log('existsSync(tmpFileLocation)',existsSync(tmpFileLocation)); expect(existsSync(tmpFileLocation)).to.be.equal(true); }) .catch(err => { From 2f64944d6ce5cadb33ec28a9828d10339f19b123 Mon Sep 17 00:00:00 2001 From: Jonathan Kuleff Date: Fri, 17 Jun 2016 19:54:48 +1000 Subject: [PATCH 11/11] add e2e test to remove default output path --- tests/e2e/e2e_workflow.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index beee70a2e2a7..2b12840cebc2 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -318,6 +318,24 @@ describe('Basic end-to-end Workflow', function () { }) }); + it('Can remove the default output path', function () { + this.timeout(10000); + + var setArgs = [ + 'set', + 'defaults.outputPath', + '--remove' + ]; + + return ng(setArgs).then(() => { + const settings = fs.readFileSync(path.join(process.cwd(), 'angular-cli.json'), 'utf-8'); + expect(settings).to.not.include('"outputPath":'); + }) + .catch(err => { + throw new Error(err) + }); + }); + it.skip('Installs sass support successfully', function() { this.timeout(420000);