Skip to content

Commit

Permalink
template copy update
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Singh committed May 14, 2020
1 parent af30471 commit 838dd46
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ yarn create is available in Yarn 0.25+


```bash
cd node_demo/lib/module
cd node_demo/lib/module/v1
```

#### npx
```bash
npx create-nodejs-project-module node_demo
npx create-nodejs-project-module <module name>
```

#### npm
Expand Down
27 changes: 26 additions & 1 deletion create-nodejs-structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ const url = require('url');
const hyperquest = require('hyperquest');
const envinfo = require('envinfo');
const os = require('os');
const replace = require('replace-in-file');

const packageJson = require('./package.json');

const tarballURL = "https://codeload.github.com/rahul2104/create-nodejs-structure/tar.gz/master"
const tarballURL = path.join(__dirname)

// These files should be allowed to remain on a failed install,
// but then silently removed during the next create.
Expand Down Expand Up @@ -250,6 +251,20 @@ async function run(
path.join(root, 'public/apiDocsV1/swagger.json'),
JSON.stringify(appPackageSwagger, null, 2) + os.EOL
);

const optionsEnv = {
files: path.join(root,`.env`),
from: [/Demo/g,/demo/g],
to: [`${appName}`,`${appName}`],
};
await fileUpdate(optionsEnv)

const optionsServer = {
files: path.join(root,`server.js`),
from: [/Nodejs/g,],
to: [`${appName.toUpperCase()}`],
};
await fileUpdate(optionsServer)


const displayedCommand = useYarn ? 'yarn' : 'npm';
Expand Down Expand Up @@ -362,6 +377,16 @@ async function createTemplate(tarball, root) {
}
}

async function fileUpdate(options) {
try {
const results = await replace(options)
console.log('Replacement results:', results);
}
catch (error) {
console.error('Error occurred:', error);
}
}

function checkAppName(appName) {
const validationResult = validateProjectName(appName);
if (!validationResult.validForNewPackages) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-nodejs-structure",
"description": "Initialize a node structure with create-nodejs-structure",
"version": "1.0.14",
"version": "1.0.20",
"license": "MIT",
"author": {
"name": "Rahul Singh"
Expand Down Expand Up @@ -31,6 +31,7 @@
"envinfo": "6.0.1",
"fs-extra": "7.0.1",
"hyperquest": "2.1.3",
"replace-in-file": "^6.0.0",
"tar-pack": "3.4.1",
"tmp": "0.0.33",
"validate-npm-package-name": "3.0.0"
Expand Down
8 changes: 4 additions & 4 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ base url -
Basic Auth api security

basic auth credentials
username- demo_admin
password - admin@demo
username- demo
password - demo

## Staging server
base url -
Expand All @@ -91,6 +91,6 @@ base url -
http://localhost:5001/apiDocs/v1/
```Shell
basic auth credentials
username- demo_admin
password - admin@demo
username- demo
password - demo
```

0 comments on commit 838dd46

Please sign in to comment.