Add a copyright banner to built files

This commit is contained in:
Bubka 2023-11-27 13:18:38 +01:00
parent 7c07910acb
commit 4d062fb9f7
4 changed files with 42 additions and 9 deletions

13
package-lock.json generated
View File

@ -21,6 +21,7 @@
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"laravel-vite-plugin": "^0.8.0", "laravel-vite-plugin": "^0.8.0",
"laravel-vue-i18n": "^2.7.1", "laravel-vue-i18n": "^2.7.1",
"php-parser": "^3.1.5",
"pinia": "^2.1.6", "pinia": "^2.1.6",
"sass": "^1.67.0", "sass": "^1.67.0",
"sortablejs": "^1.15.0", "sortablejs": "^1.15.0",
@ -1443,6 +1444,12 @@
"vue": "^3.2.45" "vue": "^3.2.45"
} }
}, },
"node_modules/laravel-vue-i18n/node_modules/php-parser": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/php-parser/-/php-parser-3.1.3.tgz",
"integrity": "sha512-hPvBmnRYPqWEtMfIFOlyjQv1q75UUtxt4U+YscKIQViGmEE2Xa4BuS1B1/cZdjy7MVcwtnr0WkEsr915LgRKOw==",
"dev": true
},
"node_modules/local-pkg": { "node_modules/local-pkg": {
"version": "0.4.3", "version": "0.4.3",
"resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz", "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.3.tgz",
@ -1571,9 +1578,9 @@
"dev": true "dev": true
}, },
"node_modules/php-parser": { "node_modules/php-parser": {
"version": "3.1.3", "version": "3.1.5",
"resolved": "https://registry.npmjs.org/php-parser/-/php-parser-3.1.3.tgz", "resolved": "https://registry.npmjs.org/php-parser/-/php-parser-3.1.5.tgz",
"integrity": "sha512-hPvBmnRYPqWEtMfIFOlyjQv1q75UUtxt4U+YscKIQViGmEE2Xa4BuS1B1/cZdjy7MVcwtnr0WkEsr915LgRKOw==", "integrity": "sha512-jEY2DcbgCm5aclzBdfW86GM6VEIWcSlhTBSHN1qhJguVePlYe28GhwS0yoeLYXpM2K8y6wzLwrbq814n2PHSoQ==",
"dev": true "dev": true
}, },
"node_modules/picocolors": { "node_modules/picocolors": {

View File

@ -22,6 +22,7 @@
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"laravel-vite-plugin": "^0.8.0", "laravel-vite-plugin": "^0.8.0",
"laravel-vue-i18n": "^2.7.1", "laravel-vue-i18n": "^2.7.1",
"php-parser": "^3.1.5",
"pinia": "^2.1.6", "pinia": "^2.1.6",
"sass": "^1.67.0", "sass": "^1.67.0",
"sortablejs": "^1.15.0", "sortablejs": "^1.15.0",

18
vite.config.js vendored
View File

@ -1,8 +1,9 @@
import { defineConfig } from 'vite'; import { defineConfig } from 'vite'
import laravel from 'laravel-vite-plugin'; import laravel from 'laravel-vite-plugin'
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue'
import i18n from 'laravel-vue-i18n/vite'; import i18n from 'laravel-vue-i18n/vite'
import AutoImport from 'unplugin-auto-import/vite'; import AutoImport from 'unplugin-auto-import/vite'
import version from './vite.version'
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
@ -67,4 +68,11 @@ export default defineConfig({
'@': '/resources/js_vue3', '@': '/resources/js_vue3',
}, },
}, },
build: {
rollupOptions: {
output: {
banner: '/*! 2FAuth version ' + version + ' - Copyright (c) 2023 Bubka - https://github.com/Bubka/2FAuth */',
},
},
},
}); });

17
vite.version.js vendored Normal file
View File

@ -0,0 +1,17 @@
import * as fs from 'fs';
import { Engine } from 'php-parser';
const parser = new Engine({
parser: {
extractDoc: false,
},
ast: {
withPositions: true,
},
})
const phpFile = fs.readFileSync("./config/2fauth.php")
const phpContent = parser.parseCode(phpFile)
const version = phpContent.children[0].expr.items[0].value.value
export default version