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

Move dependencies and improve yarn detection #218

Merged
merged 5 commits into from
Jan 23, 2018
Merged
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
5 changes: 1 addition & 4 deletions element-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
"@nutmeg/seed": "0.4.2"
},
"devDependencies": {
"@nutmeg/cli": "<%= cliSource %>",
"@types/chai": "4.1.1",
"@types/mocha": "2.2.46",
"@webcomponents/webcomponentsjs": "1.1.0"
"@nutmeg/cli": "<%= cliSource %>"
}
}
2 changes: 1 addition & 1 deletion element-template/partial/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ component = fixture('<<%= tag %><%
} else if(['number', 'string'].includes(property.type)) {
print(` ${property.name}="${property.value}"`);
} %>></<%= tag %>>');<% if (!['number', 'string', 'boolean'].includes(property.type)) {
print(' /** Set typical complex property. */\n');
print('\n /** Set typical complex property. */\n');
print(` // component.${property.name} = ${property.type}`);
} %>
2 changes: 1 addition & 1 deletion element-template/src/element-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class <%= name %> extends Seed {

/** Rerender when the observed attributes change. */
public attributeChangedCallback(name: string, oldValue: any, newValue: any) {
super.attributeChangedCallback(name, oldValue, newValue)
super.attributeChangedCallback(name, oldValue, newValue);
}

/** Styling for the component. */
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@
"scripts": {
"build": "tsc",
"prepare": "npm run build",
"pretest": "mkdir tmp",
"test": "cd tmp && nutmeg new ci-test first:number second:string third:boolean --cli-source file:../.. --no-yarn && cd ci-test && npm run test",
"test:yarn": "cd tmp && nutmeg new ci-test first:number second:string third:boolean --cli-source file:../.. && cd ci-test && npm run test",
"pretest": "mkdir tmp && npm pack . && node ./scripts/rename-pack.js",
"test": "cd tmp && nutmeg new ci-test first:number second:string third:boolean --no-yarn --cli-source file:../../nutmeg-cli-latest.tgz && cd ci-test && npm run test",
"test:yarn": "cd tmp && nutmeg new ci-test first:number second:string third:boolean --yarn --cli-source file:../.. && cd ci-test && npm run test",
"watch": "tsc --watch"
},
"engines": {
"node": ">=8"
},
"dependencies": {
"@types/chai": "4.1.1",
"@types/mocha": "2.2.46",
"@webcomponents/webcomponentsjs": "1.1.0",
"babel-preset-env": "1.6.1",
"chai": "4.1.2",
"commander": "2.13.0",
Expand Down
5 changes: 5 additions & 0 deletions scripts/rename-pack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const fs = require('fs');
const path = require('path');
const pkg = require(path.resolve('./package.json'));

fs.renameSync(path.resolve(`./nutmeg-cli-${pkg.version}.tgz`), path.resolve(`./nutmeg-cli-latest.tgz`));
6 changes: 4 additions & 2 deletions src/new.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as fs from 'fs';
import * as path from 'path';
import * as program from 'commander';
import * as shell from 'shelljs';
Expand All @@ -11,7 +12,7 @@ notifyOfUpdate();

program.command('new <component-name> [property:type...]', 'generate a Web Component')
.option('--cli-source <location>', 'install @nutmeg/cli dependency from local or github')
.option('--no-yarn', 'always use NPM')
.option('--yarn', 'use Yarn to install dependencies')
.option('--no-dependencies', 'skip installing dependencies');

program.parse(process.argv);
Expand All @@ -21,6 +22,7 @@ const nutmegDir = path.resolve(process.argv[1], '../..');
const workingDir = path.resolve('./');
const cliSource = program.cliSource || require('../package.json')['version'];
const requestedProperties = program.args.slice(1);
const installedWithYarn = fs.existsSync(path.resolve(nutmegDir, 'yarn.lock'));
const properties = new Properties(requestedProperties);
const generator = new Generator(nutmegDir, workingDir, component.tag);
const data = {
Expand All @@ -39,7 +41,7 @@ generator.execute(data)
.then(() => {
shell.cd(component.tag);
commitToGit();
installDependencies({ withYarn: program.yarn, withDependencies: program.dependencies });
installDependencies({ withYarn: program.yarn || installedWithYarn, withDependencies: program.dependencies });
console.log(`🎉 Component generated`);
console.log(`🌱 Run \`npm run serve\` from ${component.tag} to start building`);
})
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function installDependencies(options: { withYarn: boolean, withDependencies: boo
console.log('📦 Skipping dependencies');
} else {
const useYarn = hasYarn() && options.withYarn;
console.log(`🎁 Installing dependencies with ${useYarn ? 'Yarn' : 'NPM'}`);
console.log(`🎁 Installing dependencies with ${useYarn ? 'Yarn' : 'NPM'}`);
if (useYarn) {
shell.exec('yarn', { silent: true });
} else {
Expand Down