Skip to content

Commit facafa3

Browse files
inital commit
0 parents  commit facafa3

File tree

14 files changed

+291
-0
lines changed

14 files changed

+291
-0
lines changed

.github/workflows/get-includes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var fs = require('fs');
2+
console.log(JSON.parse(fs.readFileSync('dist/module.json', 'utf8')).includes.join(" "));

.github/workflows/get-version.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var fs = require('fs');
2+
console.log(JSON.parse(fs.readFileSync('dist/module.json', 'utf8')).version);

.github/workflows/main.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Module CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
# Get the version from 'module.json'
15+
- name: Get Version
16+
shell: bash
17+
id: get-version
18+
run: echo "::set-output name=version::$(node ./.github/workflows/get-version.js)"
19+
20+
# Get the name from 'module.json'
21+
- name: Get Includes
22+
shell: bash
23+
id: get-includes
24+
run: echo "::set-output name=files::$(node ./.github/workflows/get-includes.js)"
25+
26+
# create a zip file with all files required by the module to add to the release
27+
- name: Zip Files
28+
run: zip -r ./module.zip ${{steps.get-includes.outputs.files}}
29+
30+
#Useful only for the template so we can leave the manifest and download urls empty
31+
- name: Substitute Manifest and Download Links For Versioned Ones
32+
id: sub_manifest_link_latest
33+
uses: microsoft/variable-substitution@v1
34+
with:
35+
files: './dist/module.json'
36+
env:
37+
url: https://github.com/${{github.repository}}
38+
manifest: https://github.com/${{github.repository}}/releases/latest/download/module.json
39+
download: https://github.com/${{github.repository}}/releases/latest/download/module.zip
40+
41+
# Update the 'latest' release
42+
- name: Update Latest Release
43+
id: create_latest_release
44+
uses: ncipollo/release-action@v1
45+
if: endsWith(github.ref, 'master')
46+
with:
47+
allowUpdates: true
48+
name: Latest
49+
draft: false
50+
prerelease: false
51+
token: ${{ secrets.GITHUB_TOKEN }}
52+
artifacts: './module.json, ./module.zip'
53+
tag: latest
54+
55+
#Substitute the Manifest and Download URLs in the module.json
56+
- name: Substitute Manifest and Download Links For Versioned Ones
57+
id: sub_manifest_link_version
58+
uses: microsoft/variable-substitution@v1
59+
with:
60+
files: './dist/module.json'
61+
env:
62+
url: https://github.com/${{github.repository}}
63+
manifest: https://github.com/${{github.repository}}/releases/download/${{steps.get-version.outputs.version}}/module.json
64+
download: https://github.com/${{github.repository}}/releases/download/${{steps.get-version.outputs.version}}/module.zip
65+
66+
# Create a release for this specific version
67+
- name: Create Version Release
68+
id: create_version_release
69+
uses: ncipollo/release-action@v1
70+
with:
71+
allowUpdates: true # set this to false if you want to prevent updating existing releases
72+
name: Release ${{ steps.get-version.outputs.version }}
73+
draft: false
74+
prerelease: false
75+
token: ${{ secrets.GITHUB_TOKEN }}
76+
artifacts: './module.json,./module.zip'
77+
tag: ${{ steps.get-version.outputs.version }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

LICENSE.MIT

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Spacemandev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Changelog
2+
*Please for the love of all that you hold dear, do everyone a favor and include a changelog here rather than making people guess at the capabilities of your module since last release*
3+
4+
# Description
5+
This is a typescript template to get you started. This is not intended for beginners.
6+
7+
Please use the javascript template as necessary for your stuff.
8+
9+
10+
## Manifest Plus
11+
Adds the following fields to the manifest for package browsers to pick up and show information better:
12+
13+
```
14+
- includes: [] # list of files to include in the zip
15+
- icon: "" # link to icon img
16+
- cover: "" #link to cover img
17+
- screenshots: [] #links to screenshot images
18+
- video: ""
19+
- authors: [
20+
{
21+
"name": "name",
22+
"email": "email",
23+
"discord": "discord"
24+
}
25+
]
26+
27+
```
28+
29+
30+
## Versioned Releases
31+
32+
The Github Actions script will automatically create a Latest release which will always have a module.json that points to the latest release, and a versioned release whenever you update the version in your module.json.
33+
34+
This allows people who depend on a specific version of your module to just install that and be version locked. The versioned releases will *not* auto update.
35+
36+
37+
# License
38+
MIT License. Do what you will. PRs welcome.

gulpfile.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const gulp = require('gulp')
2+
const ts = require('gulp-typescript');
3+
const project = ts.createProject('tsconfig.json')
4+
5+
6+
gulp.task('compile', () => {
7+
return gulp.src('src/**/*.ts')
8+
.pipe(project())
9+
.pipe(gulp.dest('dist/'))
10+
})
11+
12+
gulp.task('copy', async () => {
13+
return new Promise((resolve,reject) => {
14+
gulp.src('README.md').pipe(gulp.dest("dist/"))
15+
gulp.src("src/module.json").pipe(gulp.dest('dist/'))
16+
gulp.src("src/lang/**").pipe(gulp.dest('dist/lang/'))
17+
gulp.src("src/templates/**").pipe(gulp.dest('dist/templates/'))
18+
gulp.src("src/styles/**").pipe(gulp.dest('dist/styles/'))
19+
gulp.src("src/assets/**").pipe(gulp.dest('dist/assets/'))
20+
resolve();
21+
})
22+
})
23+
24+
gulp.task('build', gulp.parallel('compile', 'copy'));
25+
26+
27+
/*
28+
// This is supposed to copy the dist folder into the modules directory for testing. Only works if you've set it up the right way
29+
//This works if development path is FoundryVTT/Data/dev/modules/swade-item-macros
30+
const MODULEPATH = "../../../modules/swade-item-macros/"
31+
32+
gulp.task('foundry', () => {
33+
return gulp.src('dist/**').pipe(gulp.dest(MODULEPATH))
34+
})
35+
36+
gulp.task("update", gulp.series('build', 'foundry'))
37+
*/

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "foundry-typescript-template",
3+
"version": "1.0.0",
4+
"description": "Foundry VTT Typescript Template",
5+
"main": "index.js",
6+
"scripts": {
7+
"build": "gulp build"
8+
},
9+
"author": "",
10+
"license": "MIT",
11+
"devDependencies": {
12+
"gulp": "^4.0.2",
13+
"gulp-typescript": "^6.0.0-alpha.1"
14+
},
15+
"dependencies": {
16+
"@types/node": "^14.10.1",
17+
"foundry-pc-types": "gitlab:foundry-projects/foundry-pc/foundry-pc-types",
18+
"typescript": "^4.0.2"
19+
}
20+
}

src/lang/en.json

Whitespace-only changes.

src/module.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "foundry-typescript-template",
3+
"title": "Typescript Template",
4+
"description": "",
5+
"authors": [
6+
{
7+
"name": "spacemandev",
8+
"discord": "spacemandev#6256"
9+
}
10+
],
11+
"version": "0.0.1",
12+
"minimumCoreVersion": "0.6.0",
13+
"compatibleCoreVersion": "0.7.2",
14+
"url": "",
15+
"manifest": "",
16+
"download": "",
17+
"type": "module",
18+
"includes": [
19+
"dist/"
20+
],
21+
"media": [
22+
{
23+
"type": "icon",
24+
"location": ""
25+
},
26+
{
27+
"type": "cover",
28+
"location": ""
29+
},
30+
{
31+
"type": "screenshot",
32+
"location": ""
33+
}
34+
],
35+
"esmodules": [
36+
"scripts/module.js"
37+
],
38+
"styles": [
39+
"styles/module.css"
40+
],
41+
"languages": [
42+
{
43+
"lang": "en",
44+
"name": "English",
45+
"path": "lang/en.json"
46+
}
47+
],
48+
""
49+
}

0 commit comments

Comments
 (0)