@jpp-toolkit/plugin-build-lib 0.0.11

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Julien Papini
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.
@@ -0,0 +1,26 @@
1
+ import { Command } from "@jpp-toolkit/core";
2
+ import * as _oclif_core_interfaces0 from "@oclif/core/interfaces";
3
+
4
+ //#region src/lib-build-command.d.ts
5
+ declare class LibBuildCommand extends Command {
6
+ static summary: string;
7
+ static args: {
8
+ preset: _oclif_core_interfaces0.Arg<string, Record<string, unknown>>;
9
+ };
10
+ static flags: {
11
+ watch: _oclif_core_interfaces0.BooleanFlag<boolean>;
12
+ };
13
+ static examples: {
14
+ description: string;
15
+ command: string;
16
+ }[];
17
+ run(): Promise<void>;
18
+ }
19
+ //#endregion
20
+ //#region src/index.d.ts
21
+ declare const commands: {
22
+ 'build:lib': typeof LibBuildCommand;
23
+ };
24
+ //#endregion
25
+ export { commands };
26
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,76 @@
1
+ import { Command } from "@jpp-toolkit/core";
2
+ import { createTsdownConfig } from "@jpp-toolkit/tsdown-config";
3
+ import { Args, Flags } from "@oclif/core";
4
+ import { build } from "tsdown";
5
+
6
+ //#region src/lib-build-command.ts
7
+ const Preset = {
8
+ ESM: "esm",
9
+ CJS: "cjs",
10
+ HYBRID: "hybrid"
11
+ };
12
+ var LibBuildCommand = class LibBuildCommand extends Command {
13
+ static summary = "Build the project using predefined library build presets.";
14
+ static args = { preset: Args.string({
15
+ name: "preset",
16
+ required: true,
17
+ description: "The build preset to use.",
18
+ options: Object.values(Preset)
19
+ }) };
20
+ static flags = { watch: Flags.boolean({
21
+ char: "w",
22
+ description: "Watch files for changes and rebuild automatically.",
23
+ default: false
24
+ }) };
25
+ static examples = [
26
+ {
27
+ description: "Build the library using the esm preset.",
28
+ command: "<%= config.bin %> <%= command.id %> esm"
29
+ },
30
+ {
31
+ description: "Build the library using the cjs preset.",
32
+ command: "<%= config.bin %> <%= command.id %> cjs"
33
+ },
34
+ {
35
+ description: "Build the library using the hybrid preset.",
36
+ command: "<%= config.bin %> <%= command.id %> hybrid"
37
+ }
38
+ ];
39
+ async run() {
40
+ const { args, flags } = await this.parse(LibBuildCommand);
41
+ const preset = args.preset;
42
+ const { watch } = flags;
43
+ this.logger.info(`Building library using the '${preset}' preset...`);
44
+ switch (preset) {
45
+ case Preset.ESM:
46
+ await build(createTsdownConfig({
47
+ format: ["esm"],
48
+ watch
49
+ }));
50
+ break;
51
+ case Preset.CJS:
52
+ await build(createTsdownConfig({
53
+ format: ["cjs"],
54
+ watch
55
+ }));
56
+ break;
57
+ case Preset.HYBRID:
58
+ await build(createTsdownConfig({
59
+ format: ["esm", "cjs"],
60
+ watch
61
+ }));
62
+ break;
63
+ default:
64
+ this.logger.error(`Unknown preset: ${preset}`);
65
+ process.exit(1);
66
+ }
67
+ }
68
+ };
69
+
70
+ //#endregion
71
+ //#region src/index.ts
72
+ const commands = { "build:lib": LibBuildCommand };
73
+
74
+ //#endregion
75
+ export { commands };
76
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["tsdownBuild"],"sources":["../src/lib-build-command.ts","../src/index.ts"],"sourcesContent":["import { Command } from '@jpp-toolkit/core';\nimport { createTsdownConfig } from '@jpp-toolkit/tsdown-config';\nimport { Args, Flags } from '@oclif/core';\nimport { build as tsdownBuild } from 'tsdown';\n\nconst Preset = {\n ESM: 'esm',\n CJS: 'cjs',\n HYBRID: 'hybrid',\n} as const;\ntype Preset = (typeof Preset)[keyof typeof Preset];\n\nexport class LibBuildCommand extends Command {\n static override summary = 'Build the project using predefined library build presets.';\n\n static override args = {\n preset: Args.string({\n name: 'preset',\n required: true,\n description: 'The build preset to use.',\n options: Object.values(Preset),\n }),\n };\n\n static override flags = {\n watch: Flags.boolean({\n char: 'w',\n description: 'Watch files for changes and rebuild automatically.',\n default: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Build the library using the esm preset.',\n command: '<%= config.bin %> <%= command.id %> esm',\n },\n {\n description: 'Build the library using the cjs preset.',\n command: '<%= config.bin %> <%= command.id %> cjs',\n },\n {\n description: 'Build the library using the hybrid preset.',\n command: '<%= config.bin %> <%= command.id %> hybrid',\n },\n ];\n\n public async run(): Promise<void> {\n const { args, flags } = await this.parse(LibBuildCommand);\n const preset = args.preset as Preset;\n const { watch } = flags;\n\n this.logger.info(`Building library using the '${preset}' preset...`);\n\n switch (preset) {\n case Preset.ESM:\n await tsdownBuild(createTsdownConfig({ format: ['esm'], watch }));\n break;\n case Preset.CJS:\n await tsdownBuild(createTsdownConfig({ format: ['cjs'], watch }));\n break;\n case Preset.HYBRID:\n await tsdownBuild(createTsdownConfig({ format: ['esm', 'cjs'], watch }));\n break;\n default:\n this.logger.error(`Unknown preset: ${preset}`);\n process.exit(1);\n }\n }\n}\n","import { LibBuildCommand } from './lib-build-command';\n\nexport const commands = {\n 'build:lib': LibBuildCommand,\n};\n"],"mappings":";;;;;;AAKA,MAAM,SAAS;CACX,KAAK;CACL,KAAK;CACL,QAAQ;CACX;AAGD,IAAa,kBAAb,MAAa,wBAAwB,QAAQ;CACzC,OAAgB,UAAU;CAE1B,OAAgB,OAAO,EACnB,QAAQ,KAAK,OAAO;EAChB,MAAM;EACN,UAAU;EACV,aAAa;EACb,SAAS,OAAO,OAAO,OAAO;EACjC,CAAC,EACL;CAED,OAAgB,QAAQ,EACpB,OAAO,MAAM,QAAQ;EACjB,MAAM;EACN,aAAa;EACb,SAAS;EACZ,CAAC,EACL;CAED,OAAgB,WAAW;EACvB;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACJ;CAED,MAAa,MAAqB;EAC9B,MAAM,EAAE,MAAM,UAAU,MAAM,KAAK,MAAM,gBAAgB;EACzD,MAAM,SAAS,KAAK;EACpB,MAAM,EAAE,UAAU;AAElB,OAAK,OAAO,KAAK,+BAA+B,OAAO,aAAa;AAEpE,UAAQ,QAAR;GACI,KAAK,OAAO;AACR,UAAMA,MAAY,mBAAmB;KAAE,QAAQ,CAAC,MAAM;KAAE;KAAO,CAAC,CAAC;AACjE;GACJ,KAAK,OAAO;AACR,UAAMA,MAAY,mBAAmB;KAAE,QAAQ,CAAC,MAAM;KAAE;KAAO,CAAC,CAAC;AACjE;GACJ,KAAK,OAAO;AACR,UAAMA,MAAY,mBAAmB;KAAE,QAAQ,CAAC,OAAO,MAAM;KAAE;KAAO,CAAC,CAAC;AACxE;GACJ;AACI,SAAK,OAAO,MAAM,mBAAmB,SAAS;AAC9C,YAAQ,KAAK,EAAE;;;;;;;AChE/B,MAAa,WAAW,EACpB,aAAa,iBAChB"}
@@ -0,0 +1,13 @@
1
+ export default {
2
+ description: 'Plugin that add the library build command to the jpp cli.',
3
+ commands: {
4
+ strategy: 'explicit',
5
+ target: './dist/index.mjs',
6
+ identifier: 'commands',
7
+ },
8
+ topics: {
9
+ build: {
10
+ description: 'Commands for building code.',
11
+ },
12
+ },
13
+ };
@@ -0,0 +1,51 @@
1
+ {
2
+ "commands": {
3
+ "build:lib": {
4
+ "aliases": [],
5
+ "args": {
6
+ "preset": {
7
+ "description": "The build preset to use.",
8
+ "name": "preset",
9
+ "options": [
10
+ "esm",
11
+ "cjs",
12
+ "hybrid"
13
+ ],
14
+ "required": true
15
+ }
16
+ },
17
+ "examples": [
18
+ {
19
+ "description": "Build the library using the esm preset.",
20
+ "command": "<%= config.bin %> <%= command.id %> esm"
21
+ },
22
+ {
23
+ "description": "Build the library using the cjs preset.",
24
+ "command": "<%= config.bin %> <%= command.id %> cjs"
25
+ },
26
+ {
27
+ "description": "Build the library using the hybrid preset.",
28
+ "command": "<%= config.bin %> <%= command.id %> hybrid"
29
+ }
30
+ ],
31
+ "flags": {
32
+ "watch": {
33
+ "char": "w",
34
+ "description": "Watch files for changes and rebuild automatically.",
35
+ "name": "watch",
36
+ "allowNo": false,
37
+ "type": "boolean"
38
+ }
39
+ },
40
+ "hasDynamicHelp": false,
41
+ "hiddenAliases": [],
42
+ "id": "build:lib",
43
+ "pluginAlias": "@jpp-toolkit/plugin-build-lib",
44
+ "pluginName": "@jpp-toolkit/plugin-build-lib",
45
+ "pluginType": "core",
46
+ "strict": true,
47
+ "summary": "Build the project using predefined library build presets."
48
+ }
49
+ },
50
+ "version": "0.0.11"
51
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@jpp-toolkit/plugin-build-lib",
3
+ "version": "0.0.11",
4
+ "description": "Plugin that add the library build command to the jpp cli.",
5
+ "keywords": [
6
+ "jpp",
7
+ "plugin",
8
+ "build",
9
+ "lib"
10
+ ],
11
+ "homepage": "https://github.com/jpapini/jpp-toolkit/tree/main/packages/plugin-build-lib#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/jpapini/jpp-toolkit/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/jpapini/jpp-toolkit.git",
18
+ "directory": "packages/plugin-build-lib"
19
+ },
20
+ "license": "MIT",
21
+ "author": "Julien Papini <julien.papini@gmail.com> (https://github.com/jpapini)",
22
+ "type": "module",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.mts",
26
+ "default": "./dist/index.mjs"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "src",
33
+ "oclif.config.js",
34
+ "oclif.manifest.json"
35
+ ],
36
+ "dependencies": {
37
+ "@oclif/core": "4.8.0",
38
+ "tsdown": "0.17.0",
39
+ "@jpp-toolkit/core": "0.0.11",
40
+ "@jpp-toolkit/tsdown-config": "0.0.11",
41
+ "@jpp-toolkit/utils": "0.0.11"
42
+ },
43
+ "devDependencies": {
44
+ "oclif": "4.22.52"
45
+ },
46
+ "engines": {
47
+ "node": "24",
48
+ "pnpm": "10"
49
+ },
50
+ "volta": {
51
+ "extends": "../../package.json"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "scripts": {
57
+ "typecheck": "tsc --noEmit --pretty",
58
+ "dev": "build-lib --watch",
59
+ "build": "build-lib"
60
+ }
61
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { LibBuildCommand } from './lib-build-command';
2
+
3
+ export const commands = {
4
+ 'build:lib': LibBuildCommand,
5
+ };
@@ -0,0 +1,70 @@
1
+ import { Command } from '@jpp-toolkit/core';
2
+ import { createTsdownConfig } from '@jpp-toolkit/tsdown-config';
3
+ import { Args, Flags } from '@oclif/core';
4
+ import { build as tsdownBuild } from 'tsdown';
5
+
6
+ const Preset = {
7
+ ESM: 'esm',
8
+ CJS: 'cjs',
9
+ HYBRID: 'hybrid',
10
+ } as const;
11
+ type Preset = (typeof Preset)[keyof typeof Preset];
12
+
13
+ export class LibBuildCommand extends Command {
14
+ static override summary = 'Build the project using predefined library build presets.';
15
+
16
+ static override args = {
17
+ preset: Args.string({
18
+ name: 'preset',
19
+ required: true,
20
+ description: 'The build preset to use.',
21
+ options: Object.values(Preset),
22
+ }),
23
+ };
24
+
25
+ static override flags = {
26
+ watch: Flags.boolean({
27
+ char: 'w',
28
+ description: 'Watch files for changes and rebuild automatically.',
29
+ default: false,
30
+ }),
31
+ };
32
+
33
+ static override examples = [
34
+ {
35
+ description: 'Build the library using the esm preset.',
36
+ command: '<%= config.bin %> <%= command.id %> esm',
37
+ },
38
+ {
39
+ description: 'Build the library using the cjs preset.',
40
+ command: '<%= config.bin %> <%= command.id %> cjs',
41
+ },
42
+ {
43
+ description: 'Build the library using the hybrid preset.',
44
+ command: '<%= config.bin %> <%= command.id %> hybrid',
45
+ },
46
+ ];
47
+
48
+ public async run(): Promise<void> {
49
+ const { args, flags } = await this.parse(LibBuildCommand);
50
+ const preset = args.preset as Preset;
51
+ const { watch } = flags;
52
+
53
+ this.logger.info(`Building library using the '${preset}' preset...`);
54
+
55
+ switch (preset) {
56
+ case Preset.ESM:
57
+ await tsdownBuild(createTsdownConfig({ format: ['esm'], watch }));
58
+ break;
59
+ case Preset.CJS:
60
+ await tsdownBuild(createTsdownConfig({ format: ['cjs'], watch }));
61
+ break;
62
+ case Preset.HYBRID:
63
+ await tsdownBuild(createTsdownConfig({ format: ['esm', 'cjs'], watch }));
64
+ break;
65
+ default:
66
+ this.logger.error(`Unknown preset: ${preset}`);
67
+ process.exit(1);
68
+ }
69
+ }
70
+ }