Skip to content

Commit 838dd46

Browse files
author
Rahul Singh
committed
template copy update
1 parent af30471 commit 838dd46

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ yarn create is available in Yarn 0.25+
4242

4343

4444
```bash
45-
cd node_demo/lib/module
45+
cd node_demo/lib/module/v1
4646
```
4747

4848
#### npx
4949
```bash
50-
npx create-nodejs-project-module node_demo
50+
npx create-nodejs-project-module <module name>
5151
```
5252

5353
#### npm

create-nodejs-structure.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ const url = require('url');
1616
const hyperquest = require('hyperquest');
1717
const envinfo = require('envinfo');
1818
const os = require('os');
19+
const replace = require('replace-in-file');
1920

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

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

2425
// These files should be allowed to remain on a failed install,
2526
// but then silently removed during the next create.
@@ -250,6 +251,20 @@ async function run(
250251
path.join(root, 'public/apiDocsV1/swagger.json'),
251252
JSON.stringify(appPackageSwagger, null, 2) + os.EOL
252253
);
254+
255+
const optionsEnv = {
256+
files: path.join(root,`.env`),
257+
from: [/Demo/g,/demo/g],
258+
to: [`${appName}`,`${appName}`],
259+
};
260+
await fileUpdate(optionsEnv)
261+
262+
const optionsServer = {
263+
files: path.join(root,`server.js`),
264+
from: [/Nodejs/g,],
265+
to: [`${appName.toUpperCase()}`],
266+
};
267+
await fileUpdate(optionsServer)
253268

254269

255270
const displayedCommand = useYarn ? 'yarn' : 'npm';
@@ -362,6 +377,16 @@ async function createTemplate(tarball, root) {
362377
}
363378
}
364379

380+
async function fileUpdate(options) {
381+
try {
382+
const results = await replace(options)
383+
console.log('Replacement results:', results);
384+
}
385+
catch (error) {
386+
console.error('Error occurred:', error);
387+
}
388+
}
389+
365390
function checkAppName(appName) {
366391
const validationResult = validateProjectName(appName);
367392
if (!validationResult.validForNewPackages) {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "create-nodejs-structure",
33
"description": "Initialize a node structure with create-nodejs-structure",
4-
"version": "1.0.14",
4+
"version": "1.0.20",
55
"license": "MIT",
66
"author": {
77
"name": "Rahul Singh"
@@ -31,6 +31,7 @@
3131
"envinfo": "6.0.1",
3232
"fs-extra": "7.0.1",
3333
"hyperquest": "2.1.3",
34+
"replace-in-file": "^6.0.0",
3435
"tar-pack": "3.4.1",
3536
"tmp": "0.0.33",
3637
"validate-npm-package-name": "3.0.0"

template/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ base url -
7575
Basic Auth api security
7676

7777
basic auth credentials
78-
username- demo_admin
79-
password - admin@demo
78+
username- demo
79+
password - demo
8080

8181
## Staging server
8282
base url -
@@ -91,6 +91,6 @@ base url -
9191
http://localhost:5001/apiDocs/v1/
9292
```Shell
9393
basic auth credentials
94-
username- demo_admin
95-
password - admin@demo
94+
username- demo
95+
password - demo
9696
```

0 commit comments

Comments
 (0)