Skip to content

Commit 0eb76a2

Browse files
committed
Changed examples to yarn, updated versioning to use package.json
1 parent 616406c commit 0eb76a2

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

internal/generate.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,20 @@ function completionHandler(type, params) {
7878
console.log()
7979
console.log(`${chalk.bold('Inside that folder, you can run all NextJS commands, such as:')}`)
8080
console.log()
81-
console.log(chalk.cyan(` npm run dev`))
81+
console.log(chalk.cyan(` yarn dev`))
8282
console.log(' Starts the development server.')
8383
console.log()
84-
console.log(chalk.cyan(` npm run build`))
84+
console.log(chalk.cyan(` yarn build`))
8585
console.log(' Builds the app for production.')
8686
console.log()
87-
console.log(chalk.cyan(` npm run start`))
87+
console.log(chalk.cyan(` yarn start`))
8888
console.log(' Runs the built app in production mode.')
8989
console.log()
9090
console.log('You can begin by typing:')
9191
console.log()
9292
console.log(chalk.cyan(' cd') + ' site')
9393
console.log(
94-
` ${chalk.cyan(`npm install && npm run dev`)}`
94+
` ${chalk.cyan(`yarn && yarn dev`)}`
9595
)
9696
console.log()
9797
}

internal/info.json

-3
This file was deleted.

internal/unavailable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ const chalk = require('chalk');
22

33
console.log()
44
console.log(`${chalk.red('Error: ')} This command is not available in development.`)
5-
console.log(`Run ${chalk.cyan('npm run generate')} and follow the instructions.`)
5+
console.log(`Run ${chalk.cyan('yarn generate')} and follow the instructions.`)
66
console.log()

internal/upgrade.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ console.log(`${chalk.blue('Downloading repository...')}`);
1010
console.log('');
1111

1212
const internalDir = path.resolve(__dirname);
13+
if(!fs.existsSync(internalDir + '/.temp')) {
14+
fs.mkdirSync(internalDir + '/.temp');
15+
}
1316
download('Jake-Short/nextjs-docs-generator#main', `${internalDir}/.temp`, (error) => {
1417
if(error) {
1518
console.log(`${chalk.red.bold('Error: ')} There was a problem downloading the repository. (${error})`);
1619
console.log(`Update aborted.`);
1720
console.log('');
1821
}
1922
else {
20-
let jsonData = JSON.parse(fs.readFileSync(`${internalDir}/.temp/internal/info.json`, 'utf-8'));
21-
let version = jsonData.version;
22-
let currVersion = JSON.parse(fs.readFileSync(`${internalDir}/info.json`, 'utf-8')).version;
23+
let version = JSON.parse(fs.readFileSync(`${internalDir}/.temp/package.json`, 'utf-8')).version;
24+
25+
let currPackageContents = JSON.parse(fs.readFileSync(`${internalDir}/package.json`, 'utf-8'));
26+
let currVersion = JSON.parse(fs.readFileSync(`${internalDir}/package.json`, 'utf-8')).version;
2327

2428
if(currVersion === version) {
2529
console.log('');
@@ -72,10 +76,12 @@ download('Jake-Short/nextjs-docs-generator#main', `${internalDir}/.temp`, (error
7276
// Trigger update
7377
if(res.Continue === true) {
7478
const baseDir = path.resolve(__dirname, '..');
75-
76-
if(!fs.existsSync(internalDir + '/.temp')) {
77-
fs.mkdirSync(internalDir + '/.temp');
78-
}
79+
80+
// Update package.json version to new version
81+
currPackageContents.version = version;
82+
83+
// Write new package.json into site folder
84+
fs.writeFileSync(baseDir + '/package.json', JSON.stringify(currPackageContents, null, 4));
7985

8086
// Copy selected folders below
8187
if(foldersToUpdate.includes('internal')) {

internal/version.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ const chalk = require('chalk');
22
const fs = require('fs');
33
const path = require('path');
44

5-
const internalDir = path.resolve(__dirname);
5+
const baseDir = path.resolve(__dirname, '..');
66

7-
let currVersion = JSON.parse(fs.readFileSync(`${internalDir}/info.json`, 'utf-8')).version;
7+
let currVersion = JSON.parse(fs.readFileSync(`${baseDir}/package.json`, 'utf-8')).version;
88

99
console.log('');
1010
console.log(`You are on version ${chalk.cyan.bold(currVersion)}.`);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-docs-generator",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"private": true,
55
"scripts": {
66
"dev": "node internal/runtimeserver.js",

0 commit comments

Comments
 (0)