@jojomatik/nuxt-bundle 1.1.2 → 1.2.0-beta.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/modules/license-module.ts +84 -0
- package/nuxt.config.ts +9 -29
- package/package.json +6 -5
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { defineNuxtModule, useLogger } from "nuxt/kit";
|
|
2
|
+
import license from "rollup-plugin-license";
|
|
3
|
+
import { type PluginOption } from "vite";
|
|
4
|
+
|
|
5
|
+
const moduleKey = "@jojomatik/nuxt-bundle/license-module";
|
|
6
|
+
const envKey = "ALLOWED_LICENCES";
|
|
7
|
+
|
|
8
|
+
const logger = useLogger(moduleKey);
|
|
9
|
+
|
|
10
|
+
export default defineNuxtModule({
|
|
11
|
+
meta: {
|
|
12
|
+
name: moduleKey,
|
|
13
|
+
configKey: "licenseModule"
|
|
14
|
+
},
|
|
15
|
+
setup(options, nuxt) {
|
|
16
|
+
nuxt.hook("vite:extendConfig", (viteConfig) => {
|
|
17
|
+
viteConfig.plugins = viteConfig.plugins || [];
|
|
18
|
+
viteConfig.plugins.push(
|
|
19
|
+
license({
|
|
20
|
+
thirdParty: {
|
|
21
|
+
includePrivate: false,
|
|
22
|
+
allow: {
|
|
23
|
+
test: (dependency) => {
|
|
24
|
+
// Return false for unlicensed dependencies.
|
|
25
|
+
if (!dependency.license) return false;
|
|
26
|
+
|
|
27
|
+
// Load allowed licenses from environment-variable
|
|
28
|
+
const allowedLicensesFromEnv =
|
|
29
|
+
process.env[envKey]?.split(",").map((license) =>
|
|
30
|
+
license.trim()
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// Load allowed licenses from module options
|
|
34
|
+
// Allow MIT and Apache-2.0 licenses by default
|
|
35
|
+
const allowedLicenses = allowedLicensesFromEnv ?? options.allowedLicenses;
|
|
36
|
+
|
|
37
|
+
const isLicenseAllowed = allowedLicenses.includes(
|
|
38
|
+
dependency.license
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (!isLicenseAllowed) {
|
|
42
|
+
logger.error(
|
|
43
|
+
`Dependency "${dependency.name}" has a license (${dependency.license}) that is not the list of allowed licenses (${allowedLicenses.join(", ")}).`
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const requiredLicenses = [...allowedLicenses, dependency.license];
|
|
47
|
+
|
|
48
|
+
const configContent = JSON.stringify({
|
|
49
|
+
extends: "@jojomatik/nuxt-bundle",
|
|
50
|
+
licenseModule:
|
|
51
|
+
{
|
|
52
|
+
allowedLicenses: requiredLicenses
|
|
53
|
+
}
|
|
54
|
+
}, undefined, 2);
|
|
55
|
+
|
|
56
|
+
const configExample = "export default defineNuxtConfig(" + configContent + ");\n";
|
|
57
|
+
|
|
58
|
+
logger.info(
|
|
59
|
+
`You can specify allowed licenses in "nuxt.config.ts" environment variable:`
|
|
60
|
+
);
|
|
61
|
+
console.log(configExample);
|
|
62
|
+
|
|
63
|
+
logger.info(
|
|
64
|
+
`You can also specify allowed licenses via "${envKey}" environment variable (ALLOWED_LICENCES=${requiredLicenses.join(",")}).`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return isLicenseAllowed;
|
|
69
|
+
},
|
|
70
|
+
failOnUnlicensed: true,
|
|
71
|
+
failOnViolation: true
|
|
72
|
+
},
|
|
73
|
+
output: {
|
|
74
|
+
// Output file into public directory which is included in the build output.
|
|
75
|
+
file: "public/dependencies.json",
|
|
76
|
+
template(dependencies) {
|
|
77
|
+
return JSON.stringify(dependencies);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}) as PluginOption);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
package/nuxt.config.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import vuetify from "vite-plugin-vuetify";
|
|
4
|
-
import license from "rollup-plugin-license";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Returns all locales with their corresponding file names from `./locales`.
|
|
@@ -10,8 +9,11 @@ export function getLocales(): { code: string; file: string }[] {
|
|
|
10
9
|
const files = fs.readdirSync("./locales");
|
|
11
10
|
|
|
12
11
|
return files.map((file) => {
|
|
12
|
+
const code = file.split(".")[0];
|
|
13
|
+
|
|
13
14
|
return {
|
|
14
|
-
code
|
|
15
|
+
code,
|
|
16
|
+
iso: code,
|
|
15
17
|
file,
|
|
16
18
|
};
|
|
17
19
|
});
|
|
@@ -74,8 +76,11 @@ export default defineNuxtConfig({
|
|
|
74
76
|
langDir: "locales",
|
|
75
77
|
},
|
|
76
78
|
],
|
|
77
|
-
"@nuxtjs/
|
|
79
|
+
"@nuxtjs/seo",
|
|
78
80
|
],
|
|
81
|
+
licenseModule: {
|
|
82
|
+
allowedLicenses: ["MIT", "Apache-2.0"],
|
|
83
|
+
},
|
|
79
84
|
hooks: {
|
|
80
85
|
"nitro:build:before": () => {
|
|
81
86
|
const fontsDir = "public/assets/fonts/";
|
|
@@ -93,32 +98,7 @@ export default defineNuxtConfig({
|
|
|
93
98
|
ssr: {
|
|
94
99
|
noExternal: ["vuetify"],
|
|
95
100
|
},
|
|
96
|
-
plugins: [
|
|
97
|
-
vuetify(),
|
|
98
|
-
license({
|
|
99
|
-
thirdParty: {
|
|
100
|
-
includePrivate: false,
|
|
101
|
-
allow: {
|
|
102
|
-
test: (dependency) => {
|
|
103
|
-
// Return false for unlicensed dependencies.
|
|
104
|
-
if (!dependency.license) return false;
|
|
105
|
-
|
|
106
|
-
// Allow MIT and Apache-2.0 licenses.
|
|
107
|
-
return ["MIT", "Apache-2.0"].includes(dependency.license);
|
|
108
|
-
},
|
|
109
|
-
failOnUnlicensed: true,
|
|
110
|
-
failOnViolation: true,
|
|
111
|
-
},
|
|
112
|
-
output: {
|
|
113
|
-
// Output file into public directory which is included in the build output.
|
|
114
|
-
file: "public/dependencies.json",
|
|
115
|
-
template(dependencies) {
|
|
116
|
-
return JSON.stringify(dependencies);
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
}),
|
|
121
|
-
],
|
|
101
|
+
plugins: [vuetify()],
|
|
122
102
|
},
|
|
123
103
|
nitro: {
|
|
124
104
|
compressPublicAssets: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jojomatik/nuxt-bundle",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A bundle of commonly used nuxt dependencies and configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"assets",
|
|
22
22
|
"locales",
|
|
23
|
+
"modules",
|
|
23
24
|
"pages",
|
|
24
25
|
"error.vue",
|
|
25
26
|
"nuxt.config.ts",
|
|
@@ -34,8 +35,8 @@
|
|
|
34
35
|
"@nuxt/image": "1.5.0",
|
|
35
36
|
"@nuxtjs/eslint-config-typescript": "12.1.0",
|
|
36
37
|
"@nuxtjs/i18n": "8.3.0",
|
|
37
|
-
"@nuxtjs/
|
|
38
|
-
"@semantic-release/exec": "
|
|
38
|
+
"@nuxtjs/seo": "2.2.0",
|
|
39
|
+
"@semantic-release/exec": "7.1.0",
|
|
39
40
|
"@semantic-release/git": "10.0.1",
|
|
40
41
|
"@storybook/addon-essentials": "8.0.5",
|
|
41
42
|
"@storybook/addon-interactions": "8.0.5",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"@types/node": "18.19.29",
|
|
52
53
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
53
54
|
"chromatic": "11.3.0",
|
|
54
|
-
"conventional-changelog-conventionalcommits": "
|
|
55
|
+
"conventional-changelog-conventionalcommits": "9.1.0",
|
|
55
56
|
"eslint-config-prettier": "9.1.0",
|
|
56
57
|
"eslint-plugin-prettier": "5.1.3",
|
|
57
58
|
"eslint-plugin-storybook": "0.8.0",
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
"rollup": "4.14.0",
|
|
61
62
|
"rollup-plugin-license": "3.3.1",
|
|
62
63
|
"sass": "1.72.0",
|
|
63
|
-
"semantic-release": "
|
|
64
|
+
"semantic-release": "25.0.2",
|
|
64
65
|
"storybook": "8.0.5",
|
|
65
66
|
"storybook-i18n": "^3.0.1",
|
|
66
67
|
"typescript": "5.4.3",
|