taskforge-cli 0.0.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.
- package/LICENCE +21 -0
- package/README.md +83 -0
- package/dist/bin/index.js +199 -0
- package/dist/config-BKNe73ub.mjs +14 -0
- package/dist/config-qD-eCtlL.cjs +17 -0
- package/dist/config-qD-eCtlL.js +17 -0
- package/dist/exports/config.cjs +8 -0
- package/dist/exports/config.d.cts +60 -0
- package/dist/exports/config.d.mts +60 -0
- package/dist/exports/config.mjs +2 -0
- package/package.json +67 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nirvik Purkait
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Why `taskforge-cli`
|
|
2
|
+
|
|
3
|
+
Have you ever been frustrated of changing `env` variable for stanalone projects, where no build tools are used, or doesnot support loading `env` variables out of the box, and you Have to use packages like `dotenv`.
|
|
4
|
+
|
|
5
|
+
One down side is that for each mode (development / test / production), you have to keep changing the values according to the mode. Well `taskforge-cli` lets you do that out of the box.
|
|
6
|
+
|
|
7
|
+
You can achieve this with the help of a config file `tf.config.ts|js`, and as well as cli options.
|
|
8
|
+
|
|
9
|
+
## Config file
|
|
10
|
+
|
|
11
|
+
In config file you can `defult` export an `Config` object or a `defineConfig()` function which takes an object as a parameter or a function that returns an object as a parameter.
|
|
12
|
+
|
|
13
|
+
## How to use it
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
// package.json
|
|
17
|
+
|
|
18
|
+
...
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tf build", // predefined script dev | build | test
|
|
21
|
+
"foo": "tf custom foo", // custom script needs a "custom" keyword
|
|
22
|
+
"bar": "tf custom bar", // custom script needs a "custom" keyword
|
|
23
|
+
"bazz": "tf custom bazz --envFile ./.env.bazz", // custom script, loads ".env.bazz"
|
|
24
|
+
},
|
|
25
|
+
...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
scripts: {
|
|
31
|
+
build: {
|
|
32
|
+
execute: "node index.ts", // loads production env
|
|
33
|
+
},
|
|
34
|
+
foo: {
|
|
35
|
+
execute: "node foo.ts", // loads ".env" by default unless specified
|
|
36
|
+
},
|
|
37
|
+
bar: {
|
|
38
|
+
execute: "node bar.ts", // loads ".env.bar"
|
|
39
|
+
envFile: "./env/.env.bar",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Options:
|
|
46
|
+
|
|
47
|
+
### Config:
|
|
48
|
+
|
|
49
|
+
**cli option**: `--config`
|
|
50
|
+
|
|
51
|
+
**alias**: `-c`
|
|
52
|
+
|
|
53
|
+
**type**: `string`
|
|
54
|
+
|
|
55
|
+
**defult**: `process.cwd()`
|
|
56
|
+
|
|
57
|
+
If your config file is not at the root of your project, provide a relative path to the config file.
|
|
58
|
+
|
|
59
|
+
### Env file:
|
|
60
|
+
|
|
61
|
+
**cli option**: `--envFile`
|
|
62
|
+
|
|
63
|
+
**type**: `string`
|
|
64
|
+
|
|
65
|
+
Pass a specific env file for that script.
|
|
66
|
+
|
|
67
|
+
### Env directory:
|
|
68
|
+
|
|
69
|
+
**cli option**: `--envDir`
|
|
70
|
+
|
|
71
|
+
**type**: `string`
|
|
72
|
+
|
|
73
|
+
Pass a directory where your env files lives. It will load preferred `env` file depending on the script type.
|
|
74
|
+
|
|
75
|
+
If script is predefined i.e: dev | build | test, it will laod related `env` file, and if the script is custom it will load defult `.env` file.
|
|
76
|
+
|
|
77
|
+
### Executing command:
|
|
78
|
+
|
|
79
|
+
**cli option**: `--exec`
|
|
80
|
+
|
|
81
|
+
**type**: `string`
|
|
82
|
+
|
|
83
|
+
Pass a command that should execute for that script.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jiti = require('jiti');
|
|
5
|
+
var node_process = require('node:process');
|
|
6
|
+
var dotenv = require('dotenv');
|
|
7
|
+
var path = require('node:path');
|
|
8
|
+
var node_fs = require('node:fs');
|
|
9
|
+
var config = require('../config-qD-eCtlL.js');
|
|
10
|
+
var node_child_process = require('node:child_process');
|
|
11
|
+
require('zod');
|
|
12
|
+
|
|
13
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
14
|
+
const validConfigFilesOrder = [
|
|
15
|
+
"tf.config.ts",
|
|
16
|
+
"tf.config.js",
|
|
17
|
+
"tf.config.mjs",
|
|
18
|
+
"tf.config.cjs"
|
|
19
|
+
];
|
|
20
|
+
const productionEnvFileLoadingOrder = [
|
|
21
|
+
".env.production.local",
|
|
22
|
+
".env.production",
|
|
23
|
+
".env.local",
|
|
24
|
+
".env"
|
|
25
|
+
];
|
|
26
|
+
const developmentEnvFileLoadingOrder = [
|
|
27
|
+
".env.development.local",
|
|
28
|
+
".env.development",
|
|
29
|
+
".env.local",
|
|
30
|
+
".env"
|
|
31
|
+
];
|
|
32
|
+
const testEnvFileLoadingOrder = [
|
|
33
|
+
".env.test.local",
|
|
34
|
+
".env.test",
|
|
35
|
+
".env.local",
|
|
36
|
+
".env"
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const passedArguments = node_process.argv.slice(2);
|
|
40
|
+
function identifyScript() {
|
|
41
|
+
if (passedArguments.includes("dev")) {
|
|
42
|
+
return "dev";
|
|
43
|
+
} else if (passedArguments.includes("build")) {
|
|
44
|
+
return "build";
|
|
45
|
+
} else if (passedArguments.includes("test")) {
|
|
46
|
+
return "test";
|
|
47
|
+
} else if (passedArguments.includes("custom")) {
|
|
48
|
+
return passedArguments[passedArguments.findIndex((value) => value === "custom") + 1];
|
|
49
|
+
} else
|
|
50
|
+
throw new Error(
|
|
51
|
+
'No script is passed.\nIf you have a custom scripts other than predefined scripts use "tf custom <script-name>".\nRemember the script name must be next to the custom keyword'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const scriptName = identifyScript();
|
|
55
|
+
function loadEnvFile() {
|
|
56
|
+
let envFilePath;
|
|
57
|
+
if (scriptName === "dev") {
|
|
58
|
+
envFilePath = availableFile(
|
|
59
|
+
developmentEnvFileLoadingOrder,
|
|
60
|
+
finalConfig?.envDir ?? finalConfig?.scripts?.dev?.envDir ?? process.cwd()
|
|
61
|
+
);
|
|
62
|
+
if (finalConfig?.scripts?.dev?.envFile) {
|
|
63
|
+
envFilePath = finalConfig.scripts.dev.envFile;
|
|
64
|
+
}
|
|
65
|
+
} else if (scriptName === "build") {
|
|
66
|
+
envFilePath = availableFile(
|
|
67
|
+
productionEnvFileLoadingOrder,
|
|
68
|
+
finalConfig?.envDir ?? finalConfig?.scripts?.build?.envDir ?? process.cwd()
|
|
69
|
+
);
|
|
70
|
+
if (finalConfig?.scripts?.build?.envFile) {
|
|
71
|
+
envFilePath = finalConfig.scripts.build.envFile;
|
|
72
|
+
}
|
|
73
|
+
} else if (scriptName === "test") {
|
|
74
|
+
envFilePath = availableFile(
|
|
75
|
+
testEnvFileLoadingOrder,
|
|
76
|
+
finalConfig?.envDir ?? finalConfig?.scripts?.test?.envDir ?? process.cwd()
|
|
77
|
+
);
|
|
78
|
+
if (finalConfig?.scripts?.test?.envFile) {
|
|
79
|
+
envFilePath = finalConfig.scripts.test.envFile;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
envFilePath = path.join(
|
|
83
|
+
finalConfig?.envDir ?? finalConfig?.scripts?.[scriptName]?.envDir ?? process.cwd(),
|
|
84
|
+
".env"
|
|
85
|
+
);
|
|
86
|
+
if (finalConfig?.scripts?.[scriptName]?.envFile) {
|
|
87
|
+
envFilePath = finalConfig.scripts?.[scriptName].envFile;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!envFilePath || !node_fs.existsSync(envFilePath) || !node_fs.statSync(envFilePath).isFile()) {
|
|
91
|
+
console.log(`No env file detected.
|
|
92
|
+
Skipping loading env variables`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
process.env.NODE_ENV = scriptName === "dev" ? "development" : scriptName === "build" ? "production" : scriptName === "test" ? "test" : void 0;
|
|
96
|
+
dotenv.config({ path: envFilePath, quiet: true, override: true });
|
|
97
|
+
}
|
|
98
|
+
function availableFile(fileOrder, scanningDir) {
|
|
99
|
+
return fileOrder.map((f) => path.join(scanningDir, f)).find((f) => node_fs.existsSync(f));
|
|
100
|
+
}
|
|
101
|
+
const arbitaryArgumets = [];
|
|
102
|
+
function extractCliOptions() {
|
|
103
|
+
let cliOptions2 = {};
|
|
104
|
+
passedArguments.forEach((arg, idx) => {
|
|
105
|
+
if (!(arg === scriptName || arg === "custom")) {
|
|
106
|
+
arbitaryArgumets.push(arg);
|
|
107
|
+
}
|
|
108
|
+
if (arg === "-c" || arg === "--config") {
|
|
109
|
+
cliOptions2.configFileLocation = passedArguments[idx + 1];
|
|
110
|
+
arbitaryArgumets.pop();
|
|
111
|
+
}
|
|
112
|
+
if (arg.startsWith("-c=") || arg.startsWith("--config=")) {
|
|
113
|
+
cliOptions2.configFileLocation = arg.split("=")[1];
|
|
114
|
+
arbitaryArgumets.pop();
|
|
115
|
+
}
|
|
116
|
+
if (arg === "--envFile") {
|
|
117
|
+
cliOptions2.envFile = passedArguments[idx + 1];
|
|
118
|
+
arbitaryArgumets.pop();
|
|
119
|
+
}
|
|
120
|
+
if (arg.startsWith("--envFile=")) {
|
|
121
|
+
cliOptions2.envFile = arg.split("=")[1];
|
|
122
|
+
arbitaryArgumets.pop();
|
|
123
|
+
}
|
|
124
|
+
if (arg === "--envDir") {
|
|
125
|
+
cliOptions2.envDir = passedArguments[idx + 1];
|
|
126
|
+
arbitaryArgumets.pop();
|
|
127
|
+
}
|
|
128
|
+
if (arg.startsWith("--envDir=")) {
|
|
129
|
+
cliOptions2.envDir = arg.split("=")[1];
|
|
130
|
+
arbitaryArgumets.pop();
|
|
131
|
+
}
|
|
132
|
+
if (arg === "--exec") {
|
|
133
|
+
cliOptions2.execute = passedArguments[idx + 1];
|
|
134
|
+
arbitaryArgumets.pop();
|
|
135
|
+
}
|
|
136
|
+
if (arg.startsWith("--exec=")) {
|
|
137
|
+
cliOptions2.execute = arg.split("=")[1];
|
|
138
|
+
arbitaryArgumets.pop();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
if (Object.keys(cliOptions2).length === 0) {
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
return cliOptions2;
|
|
145
|
+
}
|
|
146
|
+
const cliOptions = extractCliOptions();
|
|
147
|
+
const scriptRelatedCliOptions = { ...cliOptions };
|
|
148
|
+
delete scriptRelatedCliOptions?.configFileLocation;
|
|
149
|
+
function executeConfigFile() {
|
|
150
|
+
const determinedConfigFileLocation = cliOptions?.configFileLocation ?? availableFile(validConfigFilesOrder, process.cwd());
|
|
151
|
+
if (!determinedConfigFileLocation) {
|
|
152
|
+
console.log("No config file found");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const jiti$1 = jiti.createJiti((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bin/index.js', document.baseURI).href)), {
|
|
156
|
+
interopDefault: true
|
|
157
|
+
});
|
|
158
|
+
const moduleFromConfigFile = jiti$1(path.resolve(determinedConfigFileLocation));
|
|
159
|
+
const config2 = moduleFromConfigFile?.default ?? moduleFromConfigFile;
|
|
160
|
+
const parsedConfig = config.configSchema.safeParse(config2);
|
|
161
|
+
if (!parsedConfig.success) {
|
|
162
|
+
throw new Error("Something is wrong with config file. Please correct it");
|
|
163
|
+
}
|
|
164
|
+
return parsedConfig.data;
|
|
165
|
+
}
|
|
166
|
+
const configurationFromConfigFile = executeConfigFile();
|
|
167
|
+
const scriptsDetailsFromConfigFile = configurationFromConfigFile?.scripts;
|
|
168
|
+
const scriptsFromConfig = scriptsDetailsFromConfigFile ?? {};
|
|
169
|
+
const mergedScriptDetails = {
|
|
170
|
+
...scriptsFromConfig,
|
|
171
|
+
[scriptName]: {
|
|
172
|
+
...scriptsFromConfig[scriptName] ?? {},
|
|
173
|
+
...scriptRelatedCliOptions
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const finalConfig = {
|
|
177
|
+
...configurationFromConfigFile,
|
|
178
|
+
scripts: { ...mergedScriptDetails }
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
loadEnvFile();
|
|
182
|
+
if (finalConfig?.scripts?.[scriptName]?.execute) {
|
|
183
|
+
const executableCommand = finalConfig?.scripts?.[scriptName]?.execute.split(" ");
|
|
184
|
+
const executable = executableCommand[0];
|
|
185
|
+
const command = executableCommand.slice(1).concat(arbitaryArgumets);
|
|
186
|
+
const process = node_child_process.spawn(executable, command, {
|
|
187
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
188
|
+
shell: true
|
|
189
|
+
});
|
|
190
|
+
process.stdout.on("data", (chunk) => {
|
|
191
|
+
console.log(chunk.toString());
|
|
192
|
+
});
|
|
193
|
+
process.stderr.on("data", (chunk) => {
|
|
194
|
+
console.error(chunk.toString());
|
|
195
|
+
});
|
|
196
|
+
process.on("exit", (code, signal) => {
|
|
197
|
+
console.log(`Process exited with code ${code}, signal ${signal}`);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const configSchema = z.object({
|
|
4
|
+
envDir: z.string().optional(),
|
|
5
|
+
scripts: z.custom().optional()
|
|
6
|
+
}).optional();
|
|
7
|
+
function defineConfig(config) {
|
|
8
|
+
if (typeof config === "function") {
|
|
9
|
+
return config();
|
|
10
|
+
}
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { configSchema as c, defineConfig as d };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
const configSchema = zod.z.object({
|
|
6
|
+
envDir: zod.z.string().optional(),
|
|
7
|
+
scripts: zod.z.custom().optional()
|
|
8
|
+
}).optional();
|
|
9
|
+
function defineConfig(config) {
|
|
10
|
+
if (typeof config === "function") {
|
|
11
|
+
return config();
|
|
12
|
+
}
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.configSchema = configSchema;
|
|
17
|
+
exports.defineConfig = defineConfig;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
const configSchema = zod.z.object({
|
|
6
|
+
envDir: zod.z.string().optional(),
|
|
7
|
+
scripts: zod.z.custom().optional()
|
|
8
|
+
}).optional();
|
|
9
|
+
function defineConfig(config) {
|
|
10
|
+
if (typeof config === "function") {
|
|
11
|
+
return config();
|
|
12
|
+
}
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.configSchema = configSchema;
|
|
17
|
+
exports.defineConfig = defineConfig;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type ScriptDetails = {
|
|
4
|
+
envFile?: string;
|
|
5
|
+
execute: string;
|
|
6
|
+
envDir?: string;
|
|
7
|
+
};
|
|
8
|
+
type Scripts = {
|
|
9
|
+
dev?: ScriptDetails;
|
|
10
|
+
build?: ScriptDetails;
|
|
11
|
+
test?: ScriptDetails;
|
|
12
|
+
} & Record<string, ScriptDetails>;
|
|
13
|
+
declare const configSchema: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
envDir: z.ZodOptional<z.ZodString>;
|
|
15
|
+
scripts: z.ZodOptional<z.ZodCustom<Scripts, Scripts>>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
type Config = z.infer<typeof configSchema>;
|
|
18
|
+
/**
|
|
19
|
+
* Defines and validates the CLI configuration.
|
|
20
|
+
*
|
|
21
|
+
* This helper enables strong typing and IDE autocomplete when
|
|
22
|
+
* authoring configuration files. It accepts either a plain
|
|
23
|
+
* configuration object or a factory function that returns one.
|
|
24
|
+
*
|
|
25
|
+
* When a function is provided, it is executed immediately and
|
|
26
|
+
* its return value is used as the final configuration.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { defineConfig } from "taskforge/config";
|
|
31
|
+
*
|
|
32
|
+
* export default defineConfig({
|
|
33
|
+
* envDir: ".",
|
|
34
|
+
* scripts: {
|
|
35
|
+
* build: {
|
|
36
|
+
* execute: "tsc"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* export default defineConfig(() => ({
|
|
45
|
+
* scripts: {
|
|
46
|
+
* dev: "pnpm dev"
|
|
47
|
+
* }
|
|
48
|
+
* }));
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param config - Configuration object or a function returning it
|
|
52
|
+
* @returns The resolved configuration object
|
|
53
|
+
*/
|
|
54
|
+
declare function defineConfig(config: Config | (() => Config)): {
|
|
55
|
+
envDir?: string | undefined;
|
|
56
|
+
scripts?: Scripts | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
|
|
59
|
+
export { defineConfig };
|
|
60
|
+
export type { Config };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type ScriptDetails = {
|
|
4
|
+
envFile?: string;
|
|
5
|
+
execute: string;
|
|
6
|
+
envDir?: string;
|
|
7
|
+
};
|
|
8
|
+
type Scripts = {
|
|
9
|
+
dev?: ScriptDetails;
|
|
10
|
+
build?: ScriptDetails;
|
|
11
|
+
test?: ScriptDetails;
|
|
12
|
+
} & Record<string, ScriptDetails>;
|
|
13
|
+
declare const configSchema: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
envDir: z.ZodOptional<z.ZodString>;
|
|
15
|
+
scripts: z.ZodOptional<z.ZodCustom<Scripts, Scripts>>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
type Config = z.infer<typeof configSchema>;
|
|
18
|
+
/**
|
|
19
|
+
* Defines and validates the CLI configuration.
|
|
20
|
+
*
|
|
21
|
+
* This helper enables strong typing and IDE autocomplete when
|
|
22
|
+
* authoring configuration files. It accepts either a plain
|
|
23
|
+
* configuration object or a factory function that returns one.
|
|
24
|
+
*
|
|
25
|
+
* When a function is provided, it is executed immediately and
|
|
26
|
+
* its return value is used as the final configuration.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { defineConfig } from "taskforge/config";
|
|
31
|
+
*
|
|
32
|
+
* export default defineConfig({
|
|
33
|
+
* envDir: ".",
|
|
34
|
+
* scripts: {
|
|
35
|
+
* build: {
|
|
36
|
+
* execute: "tsc"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* export default defineConfig(() => ({
|
|
45
|
+
* scripts: {
|
|
46
|
+
* dev: "pnpm dev"
|
|
47
|
+
* }
|
|
48
|
+
* }));
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param config - Configuration object or a function returning it
|
|
52
|
+
* @returns The resolved configuration object
|
|
53
|
+
*/
|
|
54
|
+
declare function defineConfig(config: Config | (() => Config)): {
|
|
55
|
+
envDir?: string | undefined;
|
|
56
|
+
scripts?: Scripts | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
|
|
59
|
+
export { defineConfig };
|
|
60
|
+
export type { Config };
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "taskforge-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A cli tool to leverage env related headache",
|
|
5
|
+
"lint-staged": {
|
|
6
|
+
"src/**/*.ts": "pnpm format"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prebuild": "rimraf ./dist",
|
|
10
|
+
"build": "pkgroll",
|
|
11
|
+
"format": "prettier --write src/**/*.ts",
|
|
12
|
+
"test": "tsx --test",
|
|
13
|
+
"pre-commit": "lint-staged"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"tf": "dist/bin/index.js"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
"./config": {
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/exports/config.d.cts",
|
|
22
|
+
"default": "./dist/exports/config.cjs"
|
|
23
|
+
},
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/exports/config.d.mts",
|
|
26
|
+
"default": "./dist/exports/config.mjs"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"keywords": [],
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"package.json"
|
|
34
|
+
],
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/nirvikpurkait/taskforge-cli.git"
|
|
38
|
+
},
|
|
39
|
+
"contributors": [
|
|
40
|
+
{
|
|
41
|
+
"email": "nirvikpurkait@gamil.com",
|
|
42
|
+
"name": "Nirvik Purkait"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/nirvikpurkait/taskforge-cli/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/nirvikpurkait/taskforge-cli",
|
|
49
|
+
"author": "",
|
|
50
|
+
"license": "ISC",
|
|
51
|
+
"packageManager": "pnpm@10.20.0",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"dotenv": "^17.2.3",
|
|
54
|
+
"jiti": "^2.6.1",
|
|
55
|
+
"zod": "^4.2.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^25.0.3",
|
|
59
|
+
"husky": "^9.1.7",
|
|
60
|
+
"lint-staged": "^16.2.7",
|
|
61
|
+
"pkgroll": "^2.21.4",
|
|
62
|
+
"prettier": "^3.7.4",
|
|
63
|
+
"rimraf": "^6.1.2",
|
|
64
|
+
"tsx": "^4.21.0",
|
|
65
|
+
"typescript": "^5.9.3"
|
|
66
|
+
}
|
|
67
|
+
}
|