makepack 1.5.7 → 1.5.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "makepack",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A CLI tool to create, build, and manage JavaScript, TypeScript, React, and React-TypeScript libraries for npm projects.",
|
|
6
6
|
"files": [
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@vitejs/plugin-react": "^4.3.4",
|
|
34
34
|
"chalk": "^5.4.1",
|
|
35
35
|
"commander": "^12.1.0",
|
|
36
|
+
"cosmiconfig": "^9.0.0",
|
|
36
37
|
"esbuild": "^0.24.2",
|
|
37
38
|
"express": "^4.21.1",
|
|
38
39
|
"figlet": "^1.8.0",
|
|
@@ -38,7 +38,6 @@ const build = async () => {
|
|
|
38
38
|
|
|
39
39
|
let tsconfig = {};
|
|
40
40
|
if (fs.existsSync(tsconfigPath)) {
|
|
41
|
-
console.log("✅ Found tsconfig.json, loading...");
|
|
42
41
|
const rawConfig = fs.readFileSync(tsconfigPath, 'utf8');
|
|
43
42
|
const parsedConfig = ts.parseConfigFileTextToJson(tsconfigPath, rawConfig);
|
|
44
43
|
if (parsedConfig.error) {
|
|
@@ -46,8 +45,6 @@ const build = async () => {
|
|
|
46
45
|
} else {
|
|
47
46
|
tsconfig = parsedConfig.config.compilerOptions || {};
|
|
48
47
|
}
|
|
49
|
-
} else {
|
|
50
|
-
console.log("⚠️ No tsconfig.json found, using default settings.");
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
tsconfig = {
|
|
@@ -56,7 +53,7 @@ const build = async () => {
|
|
|
56
53
|
skipLibCheck: true,
|
|
57
54
|
moduleResolution: ts.ModuleResolutionKind.Node10,
|
|
58
55
|
...tsconfig,
|
|
59
|
-
outDir: path.join(
|
|
56
|
+
outDir: path.join(outdir, 'types'),
|
|
60
57
|
declaration: true,
|
|
61
58
|
emitDeclarationOnly: true,
|
|
62
59
|
noEmit: false,
|
|
@@ -11,6 +11,7 @@ const publish = async () => {
|
|
|
11
11
|
logger.error(`Build directory ${buildDir} does not exist. Please build the project first`)
|
|
12
12
|
process.exit(1)
|
|
13
13
|
}
|
|
14
|
+
|
|
14
15
|
logger.info(`Publishing the production build to the npm repository...`)
|
|
15
16
|
execSync(`npm publish`, {
|
|
16
17
|
cwd: buildDir
|
package/src/makepack-config.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from 'fs-extra'
|
|
1
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
3
2
|
|
|
4
3
|
const makepackConfig = async () => {
|
|
4
|
+
const explorer = cosmiconfig("makepack");
|
|
5
|
+
const configResult = await explorer.search();
|
|
5
6
|
|
|
6
7
|
const defaultConfig = {
|
|
7
8
|
build: {
|
|
@@ -41,22 +42,16 @@ const makepackConfig = async () => {
|
|
|
41
42
|
express: (_app) => { }
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
const configPath = path.resolve(process.cwd(), "makepack.js");
|
|
45
45
|
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
console.log("Config function must return a config object")
|
|
54
|
-
process.exit(1)
|
|
55
|
-
}
|
|
56
|
-
return nc
|
|
46
|
+
if (configResult && configResult.config) {
|
|
47
|
+
let fn = configResult.config;
|
|
48
|
+
if (typeof fn === 'function') {
|
|
49
|
+
const userConfig = fn(defaultConfig)
|
|
50
|
+
if (!userConfig) {
|
|
51
|
+
console.log("Config function must return a config object")
|
|
52
|
+
process.exit(1)
|
|
57
53
|
}
|
|
58
|
-
|
|
59
|
-
console.log(error);
|
|
54
|
+
return userConfig
|
|
60
55
|
}
|
|
61
56
|
}
|
|
62
57
|
return defaultConfig
|