create-application-template 0.7.4 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
const { writeFile } = require('fs/promises')
|
|
3
3
|
const { execSync } = require('child_process')
|
|
4
|
+
const path = require('path')
|
|
4
5
|
const yargs = require('yargs/yargs')
|
|
5
6
|
const { hideBin } = require('yargs/helpers')
|
|
6
7
|
const packageJson = require('../package.json')
|
|
@@ -25,10 +26,6 @@ const run = async () => {
|
|
|
25
26
|
if (!argv.name) {
|
|
26
27
|
console.error('WARNING add a project name like so: npx create-application-template --name={my-project}')
|
|
27
28
|
process.exit(1)
|
|
28
|
-
} else {
|
|
29
|
-
console.info('')
|
|
30
|
-
console.info(`Your project name is: ${argv.name}`)
|
|
31
|
-
console.info('')
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
const projectPaths = {
|
|
@@ -38,11 +35,18 @@ const run = async () => {
|
|
|
38
35
|
get packageJson() { return `${this.root}/package.json` },
|
|
39
36
|
}
|
|
40
37
|
|
|
38
|
+
const isNameDotCommand = (argv.name === '.')
|
|
39
|
+
const projectName = isNameDotCommand ? path.basename(process.cwd()) : argv.name
|
|
40
|
+
|
|
41
|
+
console.info('')
|
|
42
|
+
console.info(`Your project name is: ${projectName}`)
|
|
43
|
+
console.info('')
|
|
44
|
+
|
|
41
45
|
// create project
|
|
42
46
|
execCommand(`curl -L ${repo} | tar zx --one-top-level=${argv.name} --strip-components 1`)
|
|
43
47
|
|
|
44
48
|
// groom project
|
|
45
|
-
if (packageJson.hasOwnProperty('name')) packageJson.name =
|
|
49
|
+
if (packageJson.hasOwnProperty('name')) packageJson.name = projectName
|
|
46
50
|
if (packageJson.hasOwnProperty('version')) packageJson.version = '1.0.0'
|
|
47
51
|
if (packageJson.hasOwnProperty('description')) packageJson.description = ''
|
|
48
52
|
if (packageJson.hasOwnProperty('author')) packageJson.author = ''
|