Skip to content
This repository was archived by the owner on Mar 30, 2021. It is now read-only.

Commit 33bced8

Browse files
authored
Merge pull request #39 from Nikhil-Vats/master
Fixed bug - npm package not installing and released new version
2 parents 50a69f8 + b9ca2c5 commit 33bced8

File tree

7 files changed

+30
-56
lines changed

7 files changed

+30
-56
lines changed

DEV_DOCS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ this.argument("projectDirectory", {
1111
});
1212
```
1313

14-
This defines the project directory argument which is entered when the generator is run. The string value stored in the `desc` above is shown when user runs the command `yo @biojs/biojs-webcomponents --help`. Each argument should have a desc field so that yeoman can provide help when user asks.
14+
This defines the project directory argument which is entered when the generator is run. The string value stored in the `desc` above is shown when user runs the command `yo biojs-webcomponents --help`. Each argument should have a desc field so that yeoman can provide help when user asks.
1515

1616
The methods listed after the `constructor` are default methods provided by yeoman which are executed in the order they are written which is -
1717
### 1. initializing()
@@ -104,7 +104,7 @@ async function(props) {
104104
`Oops! We encountered an error. Please see below for the more details - \n${chalk.yellow(
105105
err
106106
)}\n.Try this - cd into that directory and run ${chalk.cyan(
107-
"`yo @biojs/biojs-webcomponents .`"
107+
"`yo biojs-webcomponents .`"
108108
)}.`
109109
);
110110
});

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@ Step 1: Install [Yeoman](http://yeoman.io).
2121
npm install -g yo
2222
```
2323

24-
Step 2a: Install [generator-biojs-webcomponents](https://www.npmjs.com/package/@biojs/generator-biojs-webcomponents).
24+
Step 2a: Install [generator-biojs-webcomponents](https://www.npmjs.com/package/generator-biojs-webcomponents).
2525

2626
```
27-
npm install -g yo @biojs/biojs-webcomponents
27+
npm install -g yo generator-biojs-webcomponents
2828
```
2929

3030
Step 2b: Generate your new project.
3131

3232
```
33-
i) yo @biojs/biojs-webcomponents
33+
i) yo biojs-webcomponents
3434
```
3535
This will make a **new directory** named `web-component` in the **current directory**. The `web-component` directory will be your **project directory**. If there is already a directory with the name `web-component`, the generator will not make a new one, rather **the existing one will be your project directory**.
3636

3737
OR
3838

3939
```
40-
ii) yo @biojs/biojs-webcomponents .
40+
ii) yo biojs-webcomponents .
4141
```
4242
This will run the generator in the **current directory**.
4343

4444
OR
4545

4646
```
47-
iii) yo @biojs/biojs-webcomponents /anyPath/yourNewProjectDir
47+
iii) yo biojs-webcomponents /anyPath/yourNewProjectDir
4848
```
4949
This will run the generator in a new directory named `yourNewProjectDir` (you can choose any other name), the new directory will be created at the **path you specified**. If there is already a directory with the same name as you provided, the generator will not make a new one, rather **the existing one will be your project directory**.
5050

@@ -106,7 +106,7 @@ If you face any issue, feel free to contact us at [Gitter](https://gitter.im/bio
106106

107107
## III. Workflow and Questions
108108

109-
After running ```yo @biojs/biojs-webcomponents``` in your terminal, you will be asked -
109+
After running ```yo biojs-webcomponents``` in your terminal, you will be asked -
110110

111111
```
112112
? Press Enter key to get going!

__tests__/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ describe("generator-biojs-webcomponents:app - Upgrade an existing component by i
158158
});
159159

160160
describe("generator-biojs-webcomponents:app - Upgrade an existing component by installing component from npm package", () => {
161-
it("installs the latest component from its npm package if user enters a valid version", async () => {
162-
jest.setTimeout(10000); // Increases timeout for this test
161+
it("throws an error if version entered does not exist", async () => {
163162
let res = await validators.checkVersionAndInstallComponent("latest", {
164163
packageNameToInstallComponent: "is-odd"
165164
});

generators/app/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ module.exports = class extends Generator {
321321
if (props.importFrom === upgradeComponentPrompts[0].choices[0]) {
322322
return this.prompt(installNpmPackagePrompts).then(props => {
323323
// If user chooses to go back and choose source of importing file again
324+
this.npmProps = props;
324325
if (props.changeImportSourceFromNpmPackage) {
325326
return recursivePromptExecution(
326327
props.changeImportSourceFromNpmPackage
@@ -469,6 +470,21 @@ module.exports = class extends Generator {
469470
this.destinationRoot("./");
470471
}
471472

473+
installingNPMPackage() {
474+
if (
475+
this.npmProps &&
476+
this.npmProps.packageNameToInstallComponent &&
477+
this.npmProps.checkVersionAndInstallComponent
478+
) {
479+
this.npmInstall(
480+
this.npmProps.packageNameToInstallComponent +
481+
"@" +
482+
this.npmProps.checkVersionAndInstallComponent,
483+
{ "save-dev": true }
484+
);
485+
}
486+
}
487+
472488
install() {
473489
this.installDependencies({
474490
npm: true,

generators/app/validator.js

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -100,51 +100,13 @@ validators.version = async function(props, answers) {
100100
validators.checkVersionAndInstallComponent = async function(props, answers) {
101101
if (props) {
102102
if (props === "latest") {
103-
let res = await executeCommand(
104-
"cd " +
105-
projectDirectory +
106-
" && npm i " +
107-
answers.packageNameToInstallComponent +
108-
"@" +
109-
props +
110-
" --save-exact",
111-
"checkVersionAndInstallComponent"
112-
)
113-
.then(() => true)
114-
.catch(err => {
115-
return chalk.red(
116-
`Oops! We encountered an error. Please see below for the more details - \n${chalk.yellow(
117-
err
118-
)}`
119-
);
120-
});
121-
return res;
103+
return true;
122104
}
123105

124106
let command =
125107
"npm view " + answers.packageNameToInstallComponent + "@" + props;
126108
let res = await executeCommand(command, "version")
127-
.then(async () => {
128-
let res = await executeCommand(
129-
"cd " +
130-
projectDirectory +
131-
" && npm i " +
132-
answers.packageNameToInstallComponent +
133-
"@" +
134-
props +
135-
" --save-exact",
136-
"checkVersionAndInstallComponent"
137-
)
138-
.then(() => true)
139-
.catch(err => {
140-
return chalk.red(
141-
`Oops! We encountered an error. Please see below for the more details - \n${chalk.yellow(
142-
err
143-
)}`
144-
);
145-
});
146-
return res;
147-
})
109+
.then(() => true)
148110
.catch(() =>
149111
chalk.red(
150112
"Sorry, the version - " +
@@ -305,10 +267,7 @@ function executeCommand(command, type) {
305267
// The command couldn't be executed
306268
spinner.stop();
307269
reject(err);
308-
} else if (
309-
type === "version" ||
310-
type === "checkVersionAndInstallComponent"
311-
) {
270+
} else if (type === "version") {
312271
// Command successfully executed
313272
if (stdout) {
314273
spinner.stop();

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-biojs-webcomponents",
3-
"version": "1.0.1",
3+
"version": "2.0.2",
44
"description": "Generate the scaffold for a BioJS component automatically so you don't have to do it yourself",
55
"homepage": "http://biojs.net",
66
"author": {

0 commit comments

Comments
 (0)