From b3b3dd1a80ff7e68eb07e97b263fbeabb98de8cb Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 1 Feb 2022 13:11:13 +0100 Subject: [PATCH] refactor: restructure files --- .gitlab-ci.yml | 2 +- LICENSE.md | 21 ++----- README.md | 24 +++----- {src/lang => lang}/de.json | 0 {src/lang => lang}/de.json.license | 0 {src/lang => lang}/en.json | 0 {src/lang => lang}/en.json.license | 0 src/module.json => module.json | 2 +- ...module.json.license => module.json.license | 0 package.json | 1 - rollup.config.js | 18 ++++-- src/{module => }/config.js | 0 .../darkness-dependent-vision-config.js | 0 src/{module => }/darkness-dependent-vision.js | 0 src/{module => }/handlebars-partials.js | 0 src/{module => }/hooks.js | 0 .../hooks/getTokenConfigHeaderButtons.js | 0 src/{module => }/hooks/init.js | 0 src/{module => }/hooks/renderTokenConfig.js | 0 src/{module => }/hooks/updateScene.js | 0 src/{module => }/hooks/updateToken.js | 0 src/{module => }/logger.js | 0 src/{module => }/setiings.js | 0 src/{module => }/shims/libWrapperShim.js | 0 src/{module => }/wrappers/token.js | 0 ...ss-dependent-vision-config-form-groups.hbs | 0 .../darkness-dependent-vision-config.hbs | 0 tools/bump-version.mjs | 22 +++----- tools/link-package.mjs | 4 +- yarn.lock | 56 +------------------ 30 files changed, 39 insertions(+), 111 deletions(-) rename {src/lang => lang}/de.json (100%) rename {src/lang => lang}/de.json.license (100%) rename {src/lang => lang}/en.json (100%) rename {src/lang => lang}/en.json.license (100%) rename src/module.json => module.json (95%) rename src/module.json.license => module.json.license (100%) rename src/{module => }/config.js (100%) rename src/{module => }/darkness-dependent-vision-config.js (100%) rename src/{module => }/darkness-dependent-vision.js (100%) rename src/{module => }/handlebars-partials.js (100%) rename src/{module => }/hooks.js (100%) rename src/{module => }/hooks/getTokenConfigHeaderButtons.js (100%) rename src/{module => }/hooks/init.js (100%) rename src/{module => }/hooks/renderTokenConfig.js (100%) rename src/{module => }/hooks/updateScene.js (100%) rename src/{module => }/hooks/updateToken.js (100%) rename src/{module => }/logger.js (100%) rename src/{module => }/setiings.js (100%) rename src/{module => }/shims/libWrapperShim.js (100%) rename src/{module => }/wrappers/token.js (100%) rename {src/templates => templates}/darkness-dependent-vision-config-form-groups.hbs (100%) rename {src/templates => templates}/darkness-dependent-vision-config.hbs (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a91f5e2..d1ab1fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,7 +92,7 @@ changelog: script: | yarn bump-version --release=${RELEASE_TYPE} RELEASE_VERSION=$(jq -r '.version' < package.json) - git add package.json src/module.json + git add package.json module.json git --no-pager diff git commit -m "chore(release): ${RELEASE_VERSION}" git tag -f ${RELEASE_VERSION} diff --git a/LICENSE.md b/LICENSE.md index d18620a..8f7f88b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -7,21 +7,12 @@ SPDX-License-Identifier: MIT This project is being developed under the terms of the [LIMITED LICENSE AGREEMENT FOR MODULE DEVELOPMENT] for Foundry Virtual Tabletop. -The project itself is licensed under multiple licenses. It is difficult to keep -this section up to date, so here is a brief summary as of June 2021: -* The images in [img] are licensed under [CC BY 4.0]. -* The files in [.yarn] by the [Yarn] Contributors are licensed under - [BSD-2-Clause]. -* Other files are licensed under [MIT]. +The project itself is licensed under multiple licenses. [REUSE] is used to +specify the licenses for the individual files. Most of the licenses are +specified either inside the source file or by an accompanying `.license` file, +but for some files, the licenses are specified in [.reuse/dep5]. -For more accurate information, check the individual files. - -[Yarn]: https://github.com/yarnpkg/berry [LIMITED LICENSE AGREEMENT FOR MODULE DEVELOPMENT]: https://foundryvtt.com/article/license/ -[CC BY 4.0]: LICENSES/CC-BY-4.0.txt -[MIT]: LICENSES/MIT.txt -[BSD-2-Clause]: LICENSES/BSD-2-Clause.txt - -[img]: img -[.yarn]: .yarn +[REUSE]: https://reuse.software/ +[.reuse/dep5]: .reuse/dep5 diff --git a/README.md b/README.md index baf43e7..8ce5e60 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ https://git.f3l.de/ghost/darkness-dependent-vision/-/raw/latest/src/module.json? ### libWrapper This module uses the [libWrapper] library for wrapping core methods. It is only -a soft dependency (a shim is provided) but it is highly recommended installing +a soft dependency (a shim is provided) but it is highly recommended to install libWrapper as a module for the best experience and compatibility with other modules. @@ -110,23 +110,13 @@ it to work. This project is being developed under the terms of the [LIMITED LICENSE AGREEMENT FOR MODULE DEVELOPMENT] for Foundry Virtual Tabletop. -The project itself is licensed under multiple licenses. It is difficult to keep -this section up to date, so here is a brief summary as of June 2021: -* The images in [img] are licensed under [CC BY 4.0]. -* The files in [.yarn] by the [Yarn] Contributors are licensed under - [BSD-2-Clause]. -* Other files are licensed under [MIT]. - -For more accurate information, check the individual files. +The project itself is licensed under multiple licenses. [REUSE] is used to +specify the licenses for the individual files. Most of the licenses are +specified either inside the source file or by an accompanying `.license` file, +but for some files, the licenses are specified in [.reuse/dep5]. [Foundry Virtual Tabletop]: http://foundryvtt.com [libWrapper]: https://github.com/ruipin/fvtt-lib-wrapper -[Yarn]: https://github.com/yarnpkg/berry - [LIMITED LICENSE AGREEMENT FOR MODULE DEVELOPMENT]: https://foundryvtt.com/article/license/ -[CC BY 4.0]: LICENSES/CC-BY-4.0.txt -[MIT]: LICENSES/MIT.txt -[BSD-2-Clause]: LICENSES/BSD-2-Clause.txt - -[img]: img -[.yarn]: .yarn +[REUSE]: https://reuse.software/ +[.reuse/dep5]: .reuse/dep5 diff --git a/src/lang/de.json b/lang/de.json similarity index 100% rename from src/lang/de.json rename to lang/de.json diff --git a/src/lang/de.json.license b/lang/de.json.license similarity index 100% rename from src/lang/de.json.license rename to lang/de.json.license diff --git a/src/lang/en.json b/lang/en.json similarity index 100% rename from src/lang/en.json rename to lang/en.json diff --git a/src/lang/en.json.license b/lang/en.json.license similarity index 100% rename from src/lang/en.json.license rename to lang/en.json.license diff --git a/src/module.json b/module.json similarity index 95% rename from src/module.json rename to module.json index 6d61f62..51b1437 100644 --- a/src/module.json +++ b/module.json @@ -12,7 +12,7 @@ ], "minimumCoreVersion": "9.236", "compatibleCoreVersion": "9", - "esmodules": ["module/darkness-dependent-vision.js"], + "esmodules": ["darkness-dependent-vision.js"], "languages": [ { "lang": "de", diff --git a/src/module.json.license b/module.json.license similarity index 100% rename from src/module.json.license rename to module.json.license diff --git a/package.json b/package.json index 6820f57..01e6fb5 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "prettier": "2.5.1", "rimraf": "3.0.2", "rollup": "2.66.1", - "rollup-plugin-sourcemaps": "0.6.3", "rollup-plugin-terser": "7.0.2", "semver": "7.3.5", "yargs": "17.3.1" diff --git a/rollup.config.js b/rollup.config.js index fc1a6a9..5fcb394 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -3,17 +3,26 @@ // SPDX-License-Identifier: MIT import copy from '@guanghechen/rollup-plugin-copy'; -import sourcemaps from 'rollup-plugin-sourcemaps'; import { terser } from 'rollup-plugin-terser'; import { distDirectory, name, sourceDirectory } from './tools/const.mjs'; -const staticFiles = ['module.json', 'lang', 'templates']; +const staticFiles = [ + '.reuse', + 'lang', + 'LICENSE.md', + 'LICENSES', + 'module.json.license', + 'module.json', + 'README.md', + 'templates', +]; const isProduction = process.env.NODE_ENV === 'production'; + /** * @type {import('rollup').RollupOptions} */ const config = { - input: { [`module/${name}`]: `${sourceDirectory}/module/${name}.js` }, + input: { [`${name}`]: `${sourceDirectory}/${name}.js` }, output: { dir: distDirectory, format: 'es', @@ -21,9 +30,8 @@ const config = { assetFileNames: '[name].[ext]', }, plugins: [ - sourcemaps(), copy({ - targets: [{ src: staticFiles.map((file) => `${sourceDirectory}/${file}`), dest: distDirectory }], + targets: [{ src: staticFiles, dest: distDirectory }], }), isProduction && terser({ ecma: 2020, keep_fnames: true }), ], diff --git a/src/module/config.js b/src/config.js similarity index 100% rename from src/module/config.js rename to src/config.js diff --git a/src/module/darkness-dependent-vision-config.js b/src/darkness-dependent-vision-config.js similarity index 100% rename from src/module/darkness-dependent-vision-config.js rename to src/darkness-dependent-vision-config.js diff --git a/src/module/darkness-dependent-vision.js b/src/darkness-dependent-vision.js similarity index 100% rename from src/module/darkness-dependent-vision.js rename to src/darkness-dependent-vision.js diff --git a/src/module/handlebars-partials.js b/src/handlebars-partials.js similarity index 100% rename from src/module/handlebars-partials.js rename to src/handlebars-partials.js diff --git a/src/module/hooks.js b/src/hooks.js similarity index 100% rename from src/module/hooks.js rename to src/hooks.js diff --git a/src/module/hooks/getTokenConfigHeaderButtons.js b/src/hooks/getTokenConfigHeaderButtons.js similarity index 100% rename from src/module/hooks/getTokenConfigHeaderButtons.js rename to src/hooks/getTokenConfigHeaderButtons.js diff --git a/src/module/hooks/init.js b/src/hooks/init.js similarity index 100% rename from src/module/hooks/init.js rename to src/hooks/init.js diff --git a/src/module/hooks/renderTokenConfig.js b/src/hooks/renderTokenConfig.js similarity index 100% rename from src/module/hooks/renderTokenConfig.js rename to src/hooks/renderTokenConfig.js diff --git a/src/module/hooks/updateScene.js b/src/hooks/updateScene.js similarity index 100% rename from src/module/hooks/updateScene.js rename to src/hooks/updateScene.js diff --git a/src/module/hooks/updateToken.js b/src/hooks/updateToken.js similarity index 100% rename from src/module/hooks/updateToken.js rename to src/hooks/updateToken.js diff --git a/src/module/logger.js b/src/logger.js similarity index 100% rename from src/module/logger.js rename to src/logger.js diff --git a/src/module/setiings.js b/src/setiings.js similarity index 100% rename from src/module/setiings.js rename to src/setiings.js diff --git a/src/module/shims/libWrapperShim.js b/src/shims/libWrapperShim.js similarity index 100% rename from src/module/shims/libWrapperShim.js rename to src/shims/libWrapperShim.js diff --git a/src/module/wrappers/token.js b/src/wrappers/token.js similarity index 100% rename from src/module/wrappers/token.js rename to src/wrappers/token.js diff --git a/src/templates/darkness-dependent-vision-config-form-groups.hbs b/templates/darkness-dependent-vision-config-form-groups.hbs similarity index 100% rename from src/templates/darkness-dependent-vision-config-form-groups.hbs rename to templates/darkness-dependent-vision-config-form-groups.hbs diff --git a/src/templates/darkness-dependent-vision-config.hbs b/templates/darkness-dependent-vision-config.hbs similarity index 100% rename from src/templates/darkness-dependent-vision-config.hbs rename to templates/darkness-dependent-vision-config.hbs diff --git a/tools/bump-version.mjs b/tools/bump-version.mjs index 828b845..b832d3d 100644 --- a/tools/bump-version.mjs +++ b/tools/bump-version.mjs @@ -3,29 +3,23 @@ // SPDX-License-Identifier: MIT import fs from 'fs-extra'; -import path from 'node:path'; import semver from 'semver'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; -import { sourceDirectory } from './const.mjs'; - const getDownloadURL = (version) => `https://git.f3l.de/ghost/darkness-dependent-vision/-/releases/${version}/downloads/darkness-dependent-vision.zip`; const getChangelogURL = (version) => `https://git.f3l.de/ghost/darkness-dependent-vision/-/releases/${version}`; +const manifestPath = 'module.json'; + /** * Get the contents of the manifest file as object. - * @returns {{file: unknown, name: string}} An object describing the manifest + * @returns {unknown} An object describing the manifest */ function getManifest() { - const manifestPath = path.join(sourceDirectory, 'module.json'); - if (fs.existsSync(manifestPath)) { - return { - file: fs.readJSONSync(manifestPath), - name: 'module.json', - }; + return fs.readJSONSync(manifestPath); } } @@ -69,10 +63,10 @@ function bumpVersion(release) { console.log(`Bumping version number to '${targetVersion}'`); packageJson.version = targetVersion; fs.writeJSONSync('package.json', packageJson, { spaces: 4 }); - manifest.file.version = targetVersion; - manifest.file.download = getDownloadURL(targetVersion); - manifest.file.changelog = getChangelogURL(targetVersion); - fs.writeJSONSync(path.join(sourceDirectory, manifest.name), manifest.file, { spaces: 4 }); + manifest.version = targetVersion; + manifest.download = getDownloadURL(targetVersion); + manifest.changelog = getChangelogURL(targetVersion); + fs.writeJSONSync(manifestPath, manifest, { spaces: 4 }); } const argv = yargs(hideBin(process.argv)).usage('Usage: $0').option('release', { diff --git a/tools/link-package.mjs b/tools/link-package.mjs index cd2518f..60b6fbd 100644 --- a/tools/link-package.mjs +++ b/tools/link-package.mjs @@ -7,7 +7,7 @@ import path from 'node:path'; import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; -import { destinationDirectory, distDirectory, foundryconfigFile, name, sourceDirectory } from './const.mjs'; +import { destinationDirectory, distDirectory, foundryconfigFile, name } from './const.mjs'; /** * Get the data path of Foundry VTT based on what is configured in the {@link foundryconfigFile}. @@ -29,7 +29,7 @@ function getDataPath() { * @param {boolean} clean Whether to remove the link instead of creating it */ async function linkPackage(clean) { - if (!fs.existsSync(path.resolve(sourceDirectory, 'module.json'))) { + if (!fs.existsSync(path.resolve('module.json'))) { throw new Error('Could not find module.json'); } diff --git a/yarn.lock b/yarn.lock index 540a98a..7b6d774 100644 --- a/yarn.lock +++ b/yarn.lock @@ -348,19 +348,6 @@ __metadata: languageName: node linkType: hard -"@rollup/pluginutils@npm:^3.0.9": - version: 3.1.0 - resolution: "@rollup/pluginutils@npm:3.1.0" - dependencies: - "@types/estree": 0.0.39 - estree-walker: ^1.0.1 - picomatch: ^2.2.2 - peerDependencies: - rollup: ^1.20.0||^2.0.0 - checksum: 8be16e27863c219edbb25a4e6ec2fe0e1e451d9e917b6a43cf2ae5bc025a6b8faaa40f82a6e53b66d0de37b58ff472c6c3d57a83037ae635041f8df959d6d9aa - languageName: node - linkType: hard - "@tootallnate/once@npm:1": version: 1.1.2 resolution: "@tootallnate/once@npm:1.1.2" @@ -396,13 +383,6 @@ __metadata: languageName: node linkType: hard -"@types/estree@npm:0.0.39": - version: 0.0.39 - resolution: "@types/estree@npm:0.0.39" - checksum: 412fb5b9868f2c418126451821833414189b75cc6bf84361156feed733e3d92ec220b9d74a89e52722e03d5e241b2932732711b7497374a404fad49087adc248 - languageName: node - linkType: hard - "@types/minimist@npm:^1.2.0": version: 1.2.2 resolution: "@types/minimist@npm:1.2.2" @@ -1672,7 +1652,6 @@ __metadata: prettier: 2.5.1 rimraf: 3.0.2 rollup: 2.66.1 - rollup-plugin-sourcemaps: 0.6.3 rollup-plugin-terser: 7.0.2 semver: 7.3.5 yargs: 17.3.1 @@ -2199,13 +2178,6 @@ __metadata: languageName: node linkType: hard -"estree-walker@npm:^1.0.1": - version: 1.0.1 - resolution: "estree-walker@npm:1.0.1" - checksum: 7e70da539691f6db03a08e7ce94f394ce2eef4180e136d251af299d41f92fb2d28ebcd9a6e393e3728d7970aeb5358705ddf7209d52fbcb2dd4693f95dcf925f - languageName: node - linkType: hard - "esutils@npm:^2.0.2": version: 2.0.3 resolution: "esutils@npm:2.0.3" @@ -4943,7 +4915,7 @@ fsevents@~2.3.2: languageName: node linkType: hard -"picomatch@npm:^2.2.2, picomatch@npm:^2.2.3": +"picomatch@npm:^2.2.3": version: 2.3.0 resolution: "picomatch@npm:2.3.0" checksum: 16818720ea7c5872b6af110760dee856c8e4cd79aed1c7a006d076b1cc09eff3ae41ca5019966694c33fbd2e1cc6ea617ab10e4adac6df06556168f13be3fca2 @@ -5440,22 +5412,6 @@ fsevents@~2.3.2: languageName: node linkType: hard -"rollup-plugin-sourcemaps@npm:0.6.3": - version: 0.6.3 - resolution: "rollup-plugin-sourcemaps@npm:0.6.3" - dependencies: - "@rollup/pluginutils": ^3.0.9 - source-map-resolve: ^0.6.0 - peerDependencies: - "@types/node": ">=10.0.0" - rollup: ">=0.31.2" - peerDependenciesMeta: - "@types/node": - optional: true - checksum: bb4909a90f2e824717a67ad146b2cccc40411ee54709ffa548c47c4dfe485bd55039a5850d7640ecb2691de9dc30e3fd57287e4d74331f36fed9c263d86dd4dc - languageName: node - linkType: hard - "rollup-plugin-terser@npm:7.0.2": version: 7.0.2 resolution: "rollup-plugin-terser@npm:7.0.2" @@ -5771,16 +5727,6 @@ fsevents@~2.3.2: languageName: node linkType: hard -"source-map-resolve@npm:^0.6.0": - version: 0.6.0 - resolution: "source-map-resolve@npm:0.6.0" - dependencies: - atob: ^2.1.2 - decode-uri-component: ^0.2.0 - checksum: fe503b9e5dac1c54be835282fcfec10879434e7b3ee08a9774f230299c724a8d403484d9531276d1670c87390e0e4d1d3f92b14cca6e4a2445ea3016b786ecd4 - languageName: node - linkType: hard - "source-map-support@npm:~0.5.20": version: 0.5.20 resolution: "source-map-support@npm:0.5.20"