makepack 1.7.12 → 1.7.14
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.
- package/README.md +122 -122
- package/package.json +62 -62
- package/src/actions/build/bundler.js +131 -114
- package/src/actions/build/index.js +74 -74
- package/src/actions/create/files/gitignore.js +9 -9
- package/src/actions/create/files/main.js +36 -36
- package/src/actions/create/files/package-json.js +49 -49
- package/src/actions/create/files/project-js.js +12 -12
- package/src/actions/create/files/project-jsx.js +50 -50
- package/src/actions/create/files/project-ts.js +10 -10
- package/src/actions/create/files/project-tsx.js +50 -50
- package/src/actions/create/files/readme.md.js +62 -62
- package/src/actions/create/files/tsconfig.js +33 -33
- package/src/actions/create/index.js +95 -95
- package/src/actions/create/makeFiles.js +65 -65
- package/src/actions/release/index.js +19 -19
- package/src/actions/start/index.js +215 -176
- package/src/actions/start/vite.js +72 -68
- package/src/helpers.js +120 -53
- package/src/index.js +39 -39
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
export default async (info) => {
|
|
3
|
-
let pkgname = info.projectDirName
|
|
4
|
-
const content = `# ${pkgname}
|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/${pkgname})
|
|
7
|
-
[](https://github.com/your-username/${pkgname}/blob/main/LICENSE)
|
|
8
|
-
[](https://www.npmjs.com/package/${pkgname})
|
|
9
|
-
|
|
10
|
-
A brief description of what your package does and its purpose.
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
\`\`\`sh
|
|
15
|
-
npm install ${pkgname}
|
|
16
|
-
\`\`\`
|
|
17
|
-
|
|
18
|
-
or with yarn:
|
|
19
|
-
|
|
20
|
-
\`\`\`sh
|
|
21
|
-
yarn add ${pkgname}
|
|
22
|
-
\`\`\`
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
|
|
26
|
-
\`\`\`js
|
|
27
|
-
import { feature } from "${pkgname}";
|
|
28
|
-
|
|
29
|
-
const result = feature("example");
|
|
30
|
-
console.log(result);
|
|
31
|
-
\`\`\`
|
|
32
|
-
|
|
33
|
-
## API
|
|
34
|
-
|
|
35
|
-
### \`feature(input: string): string\`
|
|
36
|
-
Description of the function and its parameters.
|
|
37
|
-
|
|
38
|
-
## Configuration (if applicable)
|
|
39
|
-
Explain any configuration options if your package requires setup.
|
|
40
|
-
|
|
41
|
-
## Examples
|
|
42
|
-
Provide additional usage examples for clarity.
|
|
43
|
-
|
|
44
|
-
## Contributing
|
|
45
|
-
Contributions are welcome! Please follow the guidelines in [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
46
|
-
|
|
47
|
-
## License
|
|
48
|
-
|
|
49
|
-
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
50
|
-
|
|
51
|
-
## Links
|
|
52
|
-
- [GitHub Repository](https://github.com/your-username/${pkgname})
|
|
53
|
-
- [NPM Package](https://www.npmjs.com/package/${pkgname})
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
Feel free to modify this template based on your package's specific needs.
|
|
58
|
-
`;
|
|
59
|
-
return {
|
|
60
|
-
content,
|
|
61
|
-
filename: `readme.md`
|
|
62
|
-
}
|
|
1
|
+
|
|
2
|
+
export default async (info) => {
|
|
3
|
+
let pkgname = info.projectDirName
|
|
4
|
+
const content = `# ${pkgname}
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/${pkgname})
|
|
7
|
+
[](https://github.com/your-username/${pkgname}/blob/main/LICENSE)
|
|
8
|
+
[](https://www.npmjs.com/package/${pkgname})
|
|
9
|
+
|
|
10
|
+
A brief description of what your package does and its purpose.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
\`\`\`sh
|
|
15
|
+
npm install ${pkgname}
|
|
16
|
+
\`\`\`
|
|
17
|
+
|
|
18
|
+
or with yarn:
|
|
19
|
+
|
|
20
|
+
\`\`\`sh
|
|
21
|
+
yarn add ${pkgname}
|
|
22
|
+
\`\`\`
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
\`\`\`js
|
|
27
|
+
import { feature } from "${pkgname}";
|
|
28
|
+
|
|
29
|
+
const result = feature("example");
|
|
30
|
+
console.log(result);
|
|
31
|
+
\`\`\`
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
### \`feature(input: string): string\`
|
|
36
|
+
Description of the function and its parameters.
|
|
37
|
+
|
|
38
|
+
## Configuration (if applicable)
|
|
39
|
+
Explain any configuration options if your package requires setup.
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
Provide additional usage examples for clarity.
|
|
43
|
+
|
|
44
|
+
## Contributing
|
|
45
|
+
Contributions are welcome! Please follow the guidelines in [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
50
|
+
|
|
51
|
+
## Links
|
|
52
|
+
- [GitHub Repository](https://github.com/your-username/${pkgname})
|
|
53
|
+
- [NPM Package](https://www.npmjs.com/package/${pkgname})
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
Feel free to modify this template based on your package's specific needs.
|
|
58
|
+
`;
|
|
59
|
+
return {
|
|
60
|
+
content,
|
|
61
|
+
filename: `readme.md`
|
|
62
|
+
}
|
|
63
63
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
export default async () => {
|
|
2
|
-
const content = {
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"lib": [
|
|
6
|
-
"dom",
|
|
7
|
-
"dom.iterable",
|
|
8
|
-
"esnext"
|
|
9
|
-
],
|
|
10
|
-
"allowJs": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"allowSyntheticDefaultImports": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
"module": "esnext",
|
|
17
|
-
"moduleResolution": "node",
|
|
18
|
-
"resolveJsonModule": true,
|
|
19
|
-
"isolatedModules": true,
|
|
20
|
-
"noEmit": true,
|
|
21
|
-
"jsx": "react"
|
|
22
|
-
},
|
|
23
|
-
"include": ["src"],
|
|
24
|
-
"exclude": [
|
|
25
|
-
"node_modules",
|
|
26
|
-
".mpack",
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
content: JSON.stringify(content, null, 2),
|
|
32
|
-
filename: "tsconfig.json"
|
|
33
|
-
}
|
|
1
|
+
export default async () => {
|
|
2
|
+
const content = {
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"lib": [
|
|
6
|
+
"dom",
|
|
7
|
+
"dom.iterable",
|
|
8
|
+
"esnext"
|
|
9
|
+
],
|
|
10
|
+
"allowJs": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"allowSyntheticDefaultImports": true,
|
|
14
|
+
"strict": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"module": "esnext",
|
|
17
|
+
"moduleResolution": "node",
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"isolatedModules": true,
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
"jsx": "react"
|
|
22
|
+
},
|
|
23
|
+
"include": ["src"],
|
|
24
|
+
"exclude": [
|
|
25
|
+
"node_modules",
|
|
26
|
+
".mpack",
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
content: JSON.stringify(content, null, 2),
|
|
32
|
+
filename: "tsconfig.json"
|
|
33
|
+
}
|
|
34
34
|
}
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { execSync, concolor, logger } from "../../helpers.js"
|
|
2
|
-
import makeFiles from "./makeFiles.js"
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import inquirer from 'inquirer'
|
|
5
|
-
import fs from "fs-extra"
|
|
6
|
-
const cwd = process.cwd()
|
|
7
|
-
const cwdFolder = cwd.split(path.sep).pop()
|
|
8
|
-
|
|
9
|
-
const valiateProjectName = (name) => {
|
|
10
|
-
if (!name) {
|
|
11
|
-
console.error("Project name cannot be empty.");
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
15
|
-
console.error("Project name can only contain lowercase letters, numbers, and hyphens.");
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
if (name.length < 3) {
|
|
19
|
-
console.error("Project name must be at least 3 characters long.");
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
if (name.length > 50) {
|
|
23
|
-
console.error("Project name must be less than 50 characters long.");
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const create = async () => {
|
|
30
|
-
|
|
31
|
-
let info = await inquirer.prompt([
|
|
32
|
-
{
|
|
33
|
-
type: 'input',
|
|
34
|
-
name: 'pdir',
|
|
35
|
-
message: 'Enter the project name',
|
|
36
|
-
default: cwdFolder
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
type: 'list',
|
|
40
|
-
name: 'template',
|
|
41
|
-
message: 'Select a template',
|
|
42
|
-
choices: ['typescript', 'javascript', 'react with typescript', 'react with javascript'],
|
|
43
|
-
default: "typescript"
|
|
44
|
-
}
|
|
45
|
-
])
|
|
46
|
-
|
|
47
|
-
// check if the pdir is exists
|
|
48
|
-
let pdir = info.pdir.trim().replace(/\s+/g, '-').toLowerCase();
|
|
49
|
-
const isValidProjectName = valiateProjectName(pdir)
|
|
50
|
-
if (!isValidProjectName) return
|
|
51
|
-
|
|
52
|
-
if (pdir !== cwdFolder) {
|
|
53
|
-
if (fs.existsSync(path.join(cwd, pdir))) {
|
|
54
|
-
const { proceed } = await inquirer.prompt([
|
|
55
|
-
{
|
|
56
|
-
type: "confirm",
|
|
57
|
-
name: 'proceed',
|
|
58
|
-
message: "The directory already exists, do you want to overwrite it?",
|
|
59
|
-
default: "No"
|
|
60
|
-
}
|
|
61
|
-
])
|
|
62
|
-
if (!proceed) {
|
|
63
|
-
console.log('Project creation canceled.');
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const rootdir = path.join(cwd, pdir)
|
|
70
|
-
let isCurrentDir = pdir !== cwdFolder
|
|
71
|
-
logger.info("", "Creating project...", false)
|
|
72
|
-
|
|
73
|
-
if (!fs.existsSync(rootdir)) {
|
|
74
|
-
fs.mkdirSync(rootdir)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (!fs.existsSync(path.join(rootdir, 'src'))) {
|
|
78
|
-
fs.mkdirSync(path.join(rootdir, 'src'))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
await makeFiles(info)
|
|
82
|
-
|
|
83
|
-
logger.info("", "Installing Dependencies", false)
|
|
84
|
-
execSync("npm install", {
|
|
85
|
-
cwd: rootdir,
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
logger.success("Project setup complete!", "")
|
|
89
|
-
if (isCurrentDir) {
|
|
90
|
-
logger.info(`Run the development server: ${concolor.yellow("npm start")}\nEnjoy your new project! 😊`);
|
|
91
|
-
} else {
|
|
92
|
-
logger.info(`Navigate to your project directory:\n${concolor.yellow("cd " + info.pdir, false)} and Run the development server: ${concolor.yellow("npm start")}\nEnjoy your new project! 😊`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
1
|
+
import { execSync, concolor, logger } from "../../helpers.js"
|
|
2
|
+
import makeFiles from "./makeFiles.js"
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import inquirer from 'inquirer'
|
|
5
|
+
import fs from "fs-extra"
|
|
6
|
+
const cwd = process.cwd()
|
|
7
|
+
const cwdFolder = cwd.split(path.sep).pop()
|
|
8
|
+
|
|
9
|
+
const valiateProjectName = (name) => {
|
|
10
|
+
if (!name) {
|
|
11
|
+
console.error("Project name cannot be empty.");
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
15
|
+
console.error("Project name can only contain lowercase letters, numbers, and hyphens.");
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (name.length < 3) {
|
|
19
|
+
console.error("Project name must be at least 3 characters long.");
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (name.length > 50) {
|
|
23
|
+
console.error("Project name must be less than 50 characters long.");
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const create = async () => {
|
|
30
|
+
|
|
31
|
+
let info = await inquirer.prompt([
|
|
32
|
+
{
|
|
33
|
+
type: 'input',
|
|
34
|
+
name: 'pdir',
|
|
35
|
+
message: 'Enter the project name',
|
|
36
|
+
default: cwdFolder
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'list',
|
|
40
|
+
name: 'template',
|
|
41
|
+
message: 'Select a template',
|
|
42
|
+
choices: ['typescript', 'javascript', 'react with typescript', 'react with javascript'],
|
|
43
|
+
default: "typescript"
|
|
44
|
+
}
|
|
45
|
+
])
|
|
46
|
+
|
|
47
|
+
// check if the pdir is exists
|
|
48
|
+
let pdir = info.pdir.trim().replace(/\s+/g, '-').toLowerCase();
|
|
49
|
+
const isValidProjectName = valiateProjectName(pdir)
|
|
50
|
+
if (!isValidProjectName) return
|
|
51
|
+
|
|
52
|
+
if (pdir !== cwdFolder) {
|
|
53
|
+
if (fs.existsSync(path.join(cwd, pdir))) {
|
|
54
|
+
const { proceed } = await inquirer.prompt([
|
|
55
|
+
{
|
|
56
|
+
type: "confirm",
|
|
57
|
+
name: 'proceed',
|
|
58
|
+
message: "The directory already exists, do you want to overwrite it?",
|
|
59
|
+
default: "No"
|
|
60
|
+
}
|
|
61
|
+
])
|
|
62
|
+
if (!proceed) {
|
|
63
|
+
console.log('Project creation canceled.');
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const rootdir = path.join(cwd, pdir)
|
|
70
|
+
let isCurrentDir = pdir !== cwdFolder
|
|
71
|
+
logger.info("", "Creating project...", false)
|
|
72
|
+
|
|
73
|
+
if (!fs.existsSync(rootdir)) {
|
|
74
|
+
fs.mkdirSync(rootdir)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!fs.existsSync(path.join(rootdir, 'src'))) {
|
|
78
|
+
fs.mkdirSync(path.join(rootdir, 'src'))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await makeFiles(info)
|
|
82
|
+
|
|
83
|
+
logger.info("", "Installing Dependencies", false)
|
|
84
|
+
execSync("npm install", {
|
|
85
|
+
cwd: rootdir,
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
logger.success("Project setup complete!", "")
|
|
89
|
+
if (isCurrentDir) {
|
|
90
|
+
logger.info(`Run the development server: ${concolor.yellow("npm start")}\nEnjoy your new project! 😊`);
|
|
91
|
+
} else {
|
|
92
|
+
logger.info(`Navigate to your project directory:\n${concolor.yellow("cd " + info.pdir, false)} and Run the development server: ${concolor.yellow("npm start")}\nEnjoy your new project! 😊`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
96
|
export default create
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
// import makepack from "./files/makepack.js";
|
|
2
|
-
import packageJson from "./files/package-json.js";
|
|
3
|
-
import gitignore from "./files/gitignore.js";
|
|
4
|
-
import tsconfig from "./files/tsconfig.js";
|
|
5
|
-
import projectJs from "./files/project-js.js";
|
|
6
|
-
import projectJsx from "./files/project-jsx.js";
|
|
7
|
-
import projectTs from "./files/project-ts.js";
|
|
8
|
-
import projectTsx from "./files/project-tsx.js";
|
|
9
|
-
import mainjs from "./files/main.js";
|
|
10
|
-
import inquirer from 'inquirer'
|
|
11
|
-
import fs from "fs-extra"
|
|
12
|
-
import path from "path"
|
|
13
|
-
import readmeMd from "./files/readme.md.js";
|
|
14
|
-
|
|
15
|
-
export default async (info) => {
|
|
16
|
-
const files = [
|
|
17
|
-
await packageJson(info),
|
|
18
|
-
await gitignore(info),
|
|
19
|
-
await readmeMd(info),
|
|
20
|
-
await mainjs(info),
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
switch (info.template) {
|
|
24
|
-
case "typescript":
|
|
25
|
-
files.push(await projectTs(info))
|
|
26
|
-
break
|
|
27
|
-
case "react with typescript":
|
|
28
|
-
files.push(await projectTsx(info))
|
|
29
|
-
break;
|
|
30
|
-
case "javascript":
|
|
31
|
-
files.push(await projectJs(info))
|
|
32
|
-
break
|
|
33
|
-
case "react with javascript":
|
|
34
|
-
files.push(await projectJsx(info))
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// push ts config
|
|
39
|
-
if (info.template.includes("typescript")) {
|
|
40
|
-
files.push(await tsconfig(info))
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const rootdir = path.join(process.cwd(), info.pdir)
|
|
44
|
-
|
|
45
|
-
for (let file of files) {
|
|
46
|
-
// check if the file exists
|
|
47
|
-
if (fs.existsSync(path.join(rootdir, file.filename))) {
|
|
48
|
-
const { overwrite } = await inquirer.prompt([
|
|
49
|
-
{
|
|
50
|
-
type: "confirm",
|
|
51
|
-
name: 'overwrite',
|
|
52
|
-
message: `The file ${file.filename} already exists, do you want to overwrite it?`,
|
|
53
|
-
default: true
|
|
54
|
-
}
|
|
55
|
-
])
|
|
56
|
-
if (!overwrite) {
|
|
57
|
-
continue
|
|
58
|
-
} else {
|
|
59
|
-
fs.removeSync(path.join(rootdir, file.filename))
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
fs.writeFileSync(path.join(rootdir, file.filename), file.content)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
// import makepack from "./files/makepack.js";
|
|
2
|
+
import packageJson from "./files/package-json.js";
|
|
3
|
+
import gitignore from "./files/gitignore.js";
|
|
4
|
+
import tsconfig from "./files/tsconfig.js";
|
|
5
|
+
import projectJs from "./files/project-js.js";
|
|
6
|
+
import projectJsx from "./files/project-jsx.js";
|
|
7
|
+
import projectTs from "./files/project-ts.js";
|
|
8
|
+
import projectTsx from "./files/project-tsx.js";
|
|
9
|
+
import mainjs from "./files/main.js";
|
|
10
|
+
import inquirer from 'inquirer'
|
|
11
|
+
import fs from "fs-extra"
|
|
12
|
+
import path from "path"
|
|
13
|
+
import readmeMd from "./files/readme.md.js";
|
|
14
|
+
|
|
15
|
+
export default async (info) => {
|
|
16
|
+
const files = [
|
|
17
|
+
await packageJson(info),
|
|
18
|
+
await gitignore(info),
|
|
19
|
+
await readmeMd(info),
|
|
20
|
+
await mainjs(info),
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
switch (info.template) {
|
|
24
|
+
case "typescript":
|
|
25
|
+
files.push(await projectTs(info))
|
|
26
|
+
break
|
|
27
|
+
case "react with typescript":
|
|
28
|
+
files.push(await projectTsx(info))
|
|
29
|
+
break;
|
|
30
|
+
case "javascript":
|
|
31
|
+
files.push(await projectJs(info))
|
|
32
|
+
break
|
|
33
|
+
case "react with javascript":
|
|
34
|
+
files.push(await projectJsx(info))
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// push ts config
|
|
39
|
+
if (info.template.includes("typescript")) {
|
|
40
|
+
files.push(await tsconfig(info))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const rootdir = path.join(process.cwd(), info.pdir)
|
|
44
|
+
|
|
45
|
+
for (let file of files) {
|
|
46
|
+
// check if the file exists
|
|
47
|
+
if (fs.existsSync(path.join(rootdir, file.filename))) {
|
|
48
|
+
const { overwrite } = await inquirer.prompt([
|
|
49
|
+
{
|
|
50
|
+
type: "confirm",
|
|
51
|
+
name: 'overwrite',
|
|
52
|
+
message: `The file ${file.filename} already exists, do you want to overwrite it?`,
|
|
53
|
+
default: true
|
|
54
|
+
}
|
|
55
|
+
])
|
|
56
|
+
if (!overwrite) {
|
|
57
|
+
continue
|
|
58
|
+
} else {
|
|
59
|
+
fs.removeSync(path.join(rootdir, file.filename))
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fs.writeFileSync(path.join(rootdir, file.filename), file.content)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import { execSync, logger } from '../../helpers.js'
|
|
3
|
-
import fs from 'fs-extra'
|
|
4
|
-
|
|
5
|
-
const release = async () => {
|
|
6
|
-
const buildDir = path.join(process.cwd(), '.mpack')
|
|
7
|
-
const packageJsonPath = path.join(buildDir, 'package.json')
|
|
8
|
-
const exists = fs.existsSync(buildDir)
|
|
9
|
-
if (!exists || !fs.existsSync(packageJsonPath)) {
|
|
10
|
-
logger.error(`Project is not built yet. Please build the project first.`)
|
|
11
|
-
process.exit(1)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
logger.info(`Releaseing the production build to the npm repository...`)
|
|
15
|
-
execSync(`npm publish`, {
|
|
16
|
-
cwd: buildDir
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { execSync, logger } from '../../helpers.js'
|
|
3
|
+
import fs from 'fs-extra'
|
|
4
|
+
|
|
5
|
+
const release = async () => {
|
|
6
|
+
const buildDir = path.join(process.cwd(), '.mpack')
|
|
7
|
+
const packageJsonPath = path.join(buildDir, 'package.json')
|
|
8
|
+
const exists = fs.existsSync(buildDir)
|
|
9
|
+
if (!exists || !fs.existsSync(packageJsonPath)) {
|
|
10
|
+
logger.error(`Project is not built yet. Please build the project first.`)
|
|
11
|
+
process.exit(1)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
logger.info(`Releaseing the production build to the npm repository...`)
|
|
15
|
+
execSync(`npm publish`, {
|
|
16
|
+
cwd: buildDir
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
20
|
export default release
|