Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(HactoberFest): use NPM as default installer, remove Yarn from de… #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ before_script:
script: ./integrations/build.sh

cache:
yarn: true
directories:
- "node_modules"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN \
ENV CHROME_BIN=/usr/bin/chromium-browser
ENV CHROME_PATH=/usr/lib/chromium/

RUN yarn global add --silent gulp-cli yo @angular/cli && yarn cache clean
RUN npm -g install --silent gulp-cli yo @angular/cli && npm cache clean
RUN sed -i -e '/rootCheck/d' "/usr/local/share/.config/yarn/global/node_modules/yo/lib/cli.js"

COPY integrations/ integrations/
Expand Down
15 changes: 3 additions & 12 deletions __tests__/test-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,25 +354,16 @@ describe('ngx-library:app', () => {
});
});

describe('check yarn', () => {
it('should set "useYarn" to true if not using npm ', () => {
let ngLibraryApp = createNgLibraryApp({
skipInstall: true,
npm: false
});
return ngLibraryApp.then(() => {
assert.equal(ngLibraryApp.generator.useYarn, true);
});
});
describe('check npm', () => {

it('should set "useYarn" to false if using npm ', () => {
it('should set "useNpm" to false if using npm ', () => {
let ngLibraryApp = createNgLibraryApp({
skipInstall: true,
npm: true
});

return ngLibraryApp.then(() => {
assert.equal(ngLibraryApp.generator.useYarn, false);
assert.equal(ngLibraryApp.generator.useNpm, true);
});
});
});
Expand Down
29 changes: 14 additions & 15 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = class extends Generator {

this.skipDemo = this.options.skipDemo;
this.skipCache = this.options.skipCache;
this.useYarn = !this.options.npm;
this.useNpm = this.options.npm;

if (this.options.projectFolder) {
this.destinationRoot(path.join(this.destinationRoot(), this.options.projectFolder));
Expand All @@ -126,20 +126,20 @@ module.exports = class extends Generator {
};

/**
* Check if yarn is installed
* Check if npm is installed
*/
this.checkYarn = () => {
if (this.skipChecks || !this.useYarn) {
this.checkNpm = () => {
if (this.skipChecks || !this.useNpm) {
return;
}
const done = this.async();
exec('yarn --version', err => {
exec('npm --version', err => {
if (err) {
this.warning('yarn is not found on your computer.\n',
' Using npm instead');
this.useYarn = false;
this.warning('npm is not found on your computer.\n',
' Install Node.Js');
this.useNpm = false;
} else {
this.useYarn = true;
this.useNpm = true;
}
done();
});
Expand Down Expand Up @@ -365,7 +365,7 @@ module.exports = class extends Generator {

initializing() {
this.pkg = require('../package.json');
this.checkYarn();
this.checkNpm();
this.checkAngularCLI();
}

Expand Down Expand Up @@ -578,12 +578,11 @@ module.exports = class extends Generator {

this.log(yosay('All done ✌(-‿-)✌,\nHappy ng-hacking!'));
} else {
this.log(`\n\nAlmost done (1/3). Running ${this.useYarn ? chalk.green('yarn install') : chalk.green('npm install')} to install the required dependencies.`);
if (this.useYarn) {
this.yarnInstall(dependencies).then(installationDone);
} else {
if (this.useNpm) {
this.log(`\n\nAlmost done (1/3). Running ${chalk.green('npm install')} to install the required dependencies.`);
this.npmInstall(dependencies).then(installationDone);
}
} else {
this.error(`NPM / Node.JS is not found in your machine`); }
}
}
};
4 changes: 2 additions & 2 deletions app/templates/config/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ execp = (cmd, opts) => {
* @returns {Promise<number>}
*/
installDependencies = (opts) => {
return execp('yarn -v') // first try to install deps using yarn
.then(exitCode => exitCode === 0 ? execp('yarn install', opts) : execp('npm install', opts));
return execp('npm -v') // first try to install deps using yarn
.then(exitCode => exitCode === 0 ? execp('npm install', opts) : execp('yarn install', opts));
};

var exports = module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ branches:

install:
- ps: Install-Product node $env:node_version
- yarn global add gulp-cli yo @angular/cli
- yarn install
- npm -g install gulp-cli yo @angular/cli
- npm install
- npm link

test_script:
Expand Down
Loading