@dword-design/nuxt-custom-cli 0.1.0

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,30 @@
1
+ # License
2
+
3
+ Unless stated otherwise all works are:
4
+
5
+ Copyright &copy; Sebastian Landwehr <info@sebastianlandwehr.com>
6
+
7
+ and licensed under:
8
+
9
+ [MIT License](https://opensource.org/license/mit/)
10
+
11
+ ## MIT License
12
+
13
+ MIT License
14
+
15
+ Copyright (c) <year> <copyright holders>
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
18
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
19
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
21
+ following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all copies or substantial
24
+ portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
27
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
28
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
29
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
30
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,106 @@
1
+ <!-- TITLE/ -->
2
+ # @dword-design/nuxt-custom-cli
3
+ <!-- /TITLE -->
4
+
5
+ <!-- BADGES/ -->
6
+ <p>
7
+ <a href="https://npmjs.org/package/@dword-design/nuxt-custom-cli">
8
+ <img
9
+ src="https://img.shields.io/npm/v/@dword-design/nuxt-custom-cli.svg"
10
+ alt="npm version"
11
+ >
12
+ </a><img src="https://img.shields.io/badge/os-linux%20%7C%C2%A0macos%20%7C%C2%A0windows-blue" alt="Linux macOS Windows compatible"><a href="https://github.com/dword-design/nuxt-custom-cli/actions">
13
+ <img
14
+ src="https://github.com/dword-design/nuxt-custom-cli/workflows/build/badge.svg"
15
+ alt="Build status"
16
+ >
17
+ </a><a href="https://codecov.io/gh/dword-design/nuxt-custom-cli">
18
+ <img
19
+ src="https://codecov.io/gh/dword-design/nuxt-custom-cli/branch/master/graph/badge.svg"
20
+ alt="Coverage status"
21
+ >
22
+ </a><a href="https://david-dm.org/dword-design/nuxt-custom-cli">
23
+ <img src="https://img.shields.io/david/dword-design/nuxt-custom-cli" alt="Dependency status">
24
+ </a><img src="https://img.shields.io/badge/renovate-enabled-brightgreen" alt="Renovate enabled"><br/><a href="https://gitpod.io/#https://github.com/dword-design/nuxt-custom-cli">
25
+ <img
26
+ src="https://gitpod.io/button/open-in-gitpod.svg"
27
+ alt="Open in Gitpod"
28
+ width="114"
29
+ >
30
+ </a><a href="https://www.buymeacoffee.com/dword">
31
+ <img
32
+ src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg"
33
+ alt="Buy Me a Coffee"
34
+ width="114"
35
+ >
36
+ </a><a href="https://paypal.me/SebastianLandwehr">
37
+ <img
38
+ src="https://sebastianlandwehr.com/images/paypal.svg"
39
+ alt="PayPal"
40
+ width="163"
41
+ >
42
+ </a><a href="https://www.patreon.com/dworddesign">
43
+ <img
44
+ src="https://sebastianlandwehr.com/images/patreon.svg"
45
+ alt="Patreon"
46
+ width="163"
47
+ >
48
+ </a>
49
+ </p>
50
+ <!-- /BADGES -->
51
+
52
+ <!-- DESCRIPTION/ -->
53
+
54
+ <!-- /DESCRIPTION -->
55
+
56
+ <!-- INSTALL/ -->
57
+ ## Install
58
+
59
+ ```bash
60
+ # npm
61
+ $ npx nuxi module add @dword-design/nuxt-custom-cli
62
+
63
+ # Yarn
64
+ $ yarn nuxi module add @dword-design/nuxt-custom-cli
65
+ ```
66
+ <!-- /INSTALL -->
67
+
68
+ <!-- LICENSE/ -->
69
+ ## Contribute
70
+
71
+ Are you missing something or want to contribute? Feel free to file an [issue](https://github.com/dword-design/nuxt-custom-cli/issues) or a [pull request](https://github.com/dword-design/nuxt-custom-cli/pulls)! ⚙️
72
+
73
+ ## Support
74
+
75
+ Hey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:
76
+
77
+ <p>
78
+ <a href="https://www.buymeacoffee.com/dword">
79
+ <img
80
+ src="https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg"
81
+ alt="Buy Me a Coffee"
82
+ width="114"
83
+ >
84
+ </a>&nbsp;If you want to send me a one time donation. The coffee is pretty good 😊.<br/>
85
+ <a href="https://paypal.me/SebastianLandwehr">
86
+ <img
87
+ src="https://sebastianlandwehr.com/images/paypal.svg"
88
+ alt="PayPal"
89
+ width="163"
90
+ >
91
+ </a>&nbsp;Also for one time donations if you like PayPal.<br/>
92
+ <a href="https://www.patreon.com/dworddesign">
93
+ <img
94
+ src="https://sebastianlandwehr.com/images/patreon.svg"
95
+ alt="Patreon"
96
+ width="163"
97
+ >
98
+ </a>&nbsp;Here you can support me regularly, which is great so I can steadily work on projects.
99
+ </p>
100
+
101
+ Thanks a lot for your support! ❤️
102
+
103
+ ## License
104
+
105
+ [MIT License](https://opensource.org/license/mit/) © [Sebastian Landwehr](https://sebastianlandwehr.com)
106
+ <!-- /LICENSE -->
@@ -0,0 +1,6 @@
1
+ declare const _default: ({ alias, outDir, rootDir, }: {
2
+ alias: Record<string, string>;
3
+ outDir: string;
4
+ rootDir: string;
5
+ }) => Promise<import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher>;
6
+ export default _default;
package/dist/build.js ADDED
@@ -0,0 +1,33 @@
1
+ import pathLib from "node:path";
2
+ import Unimport from "unimport/unplugin";
3
+ import { build } from "vite";
4
+ export default ({
5
+ alias,
6
+ outDir,
7
+ rootDir
8
+ }) => build({
9
+ build: {
10
+ emptyOutDir: false,
11
+ lib: {
12
+ entry: pathLib.join(rootDir, "server", "cli.ts"),
13
+ fileName: "cli",
14
+ formats: ["es"]
15
+ },
16
+ outDir,
17
+ rollupOptions: {
18
+ external: [/node_modules/],
19
+ output: {
20
+ entryFileNames: "cli.mjs"
21
+ }
22
+ },
23
+ ssr: true,
24
+ target: "node22"
25
+ },
26
+ plugins: [Unimport.vite({
27
+ dirs: [pathLib.join(rootDir, "server/utils/**/*.ts")],
28
+ dts: false
29
+ })],
30
+ resolve: {
31
+ alias
32
+ }
33
+ });
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ import pathLib from "node:path";
3
+ import { execa } from "execa";
4
+ import build from "./build.js";
5
+ import { getAliasFromNuxtTsConfig } from "./get-alias-from-tsconfig.js";
6
+ const rootDir = process.cwd();
7
+ const outDir = pathLib.join(rootDir, ".nuxt");
8
+ const builtCliPath = pathLib.join(outDir, "cli.mjs");
9
+ try {
10
+ const alias = await getAliasFromNuxtTsConfig({
11
+ rootDir
12
+ });
13
+ await build({
14
+ alias,
15
+ outDir,
16
+ rootDir
17
+ });
18
+ } catch (error) {
19
+ console.error("Build failed:", error);
20
+ process.exit(1);
21
+ }
22
+ const cliArgs = process.argv.slice(2);
23
+ const child = execa("node", [builtCliPath, ...cliArgs], {
24
+ stdio: "inherit"
25
+ });
26
+ child.on("exit", code => {
27
+ process.exit(code || 0);
28
+ });
@@ -0,0 +1,6 @@
1
+ export declare const getAliasFromNuxtTsConfig: ({ rootDir, tsconfigPath, }: {
2
+ rootDir: string;
3
+ tsconfigPath?: string;
4
+ }) => Promise<{
5
+ [k: string]: any;
6
+ }>;
@@ -0,0 +1,14 @@
1
+ import pathLib from "node:path";
2
+ import fs from "fs-extra";
3
+ export const getAliasFromNuxtTsConfig = async ({
4
+ rootDir,
5
+ tsconfigPath = ".nuxt/tsconfig.server.json"
6
+ }) => {
7
+ const tsconfig = JSON.parse(await fs.readFile(pathLib.join(rootDir, tsconfigPath), "utf8"));
8
+ const paths = tsconfig.compilerOptions?.paths ?? {};
9
+ return Object.fromEntries(Object.entries(paths).filter(([key]) => key.endsWith("/*")).map(([key, value]) => {
10
+ const aliasKey = key.slice(0, -2);
11
+ const aliasValue = value[0].replace(/^\.\.\//, "").slice(0, -2);
12
+ return [aliasKey, pathLib.join(rootDir, aliasValue)];
13
+ }));
14
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@nuxt/schema").NuxtModule<import("@nuxt/schema").ModuleOptions, import("@nuxt/schema").ModuleOptions, false>;
2
+ export default _default;
package/dist/module.js ADDED
@@ -0,0 +1,20 @@
1
+ import pathLib from "node:path";
2
+ import { defineNuxtModule } from "@nuxt/kit";
3
+ import build from "./build.js";
4
+ export default defineNuxtModule({
5
+ setup: (_, nuxt) => {
6
+ const globalState = globalThis;
7
+ nuxt.hook("nitro:build:public-assets", async nitro => {
8
+ if (globalState.__knowledgeOutputCliBuilt) {
9
+ return;
10
+ }
11
+ globalState.__knowledgeOutputCliBuilt = true;
12
+ const outputPath = pathLib.join(nitro.options.output.dir, "server");
13
+ await build({
14
+ alias: nuxt.options.alias,
15
+ outDir: outputPath,
16
+ rootDir: nuxt.options.rootDir
17
+ });
18
+ });
19
+ }
20
+ });
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@dword-design/nuxt-custom-cli",
3
+ "version": "0.1.0",
4
+ "repository": "dword-design/nuxt-custom-cli",
5
+ "funding": "https://github.com/sponsors/dword-design",
6
+ "license": "MIT",
7
+ "author": "Sebastian Landwehr <info@sebastianlandwehr.com>",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "default": "./dist/module.js",
12
+ "types": "./dist/module.d.ts"
13
+ }
14
+ },
15
+ "main": "dist/module.js",
16
+ "bin": "./dist/cli.js",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "checkUnknownFiles": "base checkUnknownFiles",
22
+ "commit": "base commit",
23
+ "depcheck": "base depcheck",
24
+ "dev": "base dev",
25
+ "lint": "base lint",
26
+ "prepare": "base prepare",
27
+ "prepublishOnly": "base prepublishOnly",
28
+ "test": "base test",
29
+ "typecheck": "base typecheck",
30
+ "verify": "base verify"
31
+ },
32
+ "dependencies": {
33
+ "@nuxt/kit": "^4.3.1",
34
+ "execa": "^9.6.1",
35
+ "fs-extra": "^11.3.3"
36
+ },
37
+ "devDependencies": {
38
+ "@dword-design/base": "^16.2.3",
39
+ "@dword-design/base-config-nuxt-module": "^5.0.1",
40
+ "@playwright/test": "^1.58.2",
41
+ "@types/fs-extra": "^11.0.4",
42
+ "@types/node": "^25.3.2",
43
+ "nuxt": "^4.3.1",
44
+ "output-files": "^4.0.0",
45
+ "unimport": "^6.0.0",
46
+ "vite": "^7.3.1"
47
+ },
48
+ "peerDependencies": {
49
+ "unimport": "*",
50
+ "vite": "*"
51
+ },
52
+ "packageManager": "pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017",
53
+ "engines": {
54
+ "node": ">=22"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ }
59
+ }