refactor: restructure files

This commit is contained in:
Johannes Loher 2022-02-01 13:11:13 +01:00
parent c8f447e8ed
commit b3b3dd1a80
30 changed files with 39 additions and 111 deletions

View file

@ -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}

View file

@ -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

View file

@ -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

View file

@ -12,7 +12,7 @@
],
"minimumCoreVersion": "9.236",
"compatibleCoreVersion": "9",
"esmodules": ["module/darkness-dependent-vision.js"],
"esmodules": ["darkness-dependent-vision.js"],
"languages": [
{
"lang": "de",

View file

@ -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"

View file

@ -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 }),
],

View file

@ -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', {

View file

@ -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');
}

View file

@ -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"