Skip to content

Commit dc7adc0

Browse files
authored
Added new WIDL module template (#10)
1 parent 79bfcb7 commit dc7adc0

11 files changed

+217
-0
lines changed

templates/module/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
docs
4+
coverage

templates/module/.template

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: module
2+
description: A WIDL codegen project
3+
variables:
4+
5+
- name: module
6+
description: The module name
7+
prompt: Please enter the module name (e.g. @widl/mymodule)
8+
9+
- name: description
10+
description: The module description
11+
prompt: Please enter the module description
12+
13+
- name: version
14+
description: The module version
15+
prompt: Please enter the version
16+
default: 0.0.1
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/eslint-recommended",
8+
"plugin:@typescript-eslint/recommended"
9+
],
10+
"rules": {
11+
"no-console": 1
12+
}
13+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @type {Partial<jest.InitialOptions>}
3+
*/
4+
const config = {
5+
preset: "ts-jest",
6+
rootDir: "..",
7+
testMatch: [
8+
"<rootDir>/src/**/__tests__/**/*.ts?(x)",
9+
"<rootDir>/src/**/?(*.)+(spec|test).ts?(x)",
10+
],
11+
testPathIgnorePatterns: ["dist"],
12+
coverageThreshold: {
13+
global: {
14+
branches: 80,
15+
functions: 80,
16+
lines: 80,
17+
statements: 80,
18+
},
19+
},
20+
setupFiles: ["<rootDir>/config/setup-tests.js"],
21+
watchPlugins: [
22+
"jest-watch-typeahead/filename",
23+
"jest-watch-typeahead/testname",
24+
],
25+
};
26+
27+
module.exports = config;
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import commonjs from "@rollup/plugin-commonjs";
2+
import resolve from "@rollup/plugin-node-resolve";
3+
import pkg from "../package.json";
4+
5+
export default [
6+
// browser-friendly UMD build
7+
{
8+
input: "dist/cjs/index.js",
9+
external: [
10+
"@wapc/widl",
11+
"@wapc/widl/ast"
12+
],
13+
output: {
14+
name: "widl.codegen",
15+
file: pkg.browser,
16+
format: "umd",
17+
sourcemap: true,
18+
globals: {
19+
'@wapc/widl': 'widl',
20+
'@wapc/widl/ast': 'widl.ast'
21+
}
22+
},
23+
plugins: [commonjs(), resolve()],
24+
},
25+
];
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// add here any code that you wanna execute before tests like
2+
// - polyfills
3+
// - some custom code
4+
// for more docs check see https://jestjs.io/docs/en/configuration.html#setupfiles-array

templates/module/config/tsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"target": "es2017",
5+
"module": "commonjs",
6+
"allowJs": true,
7+
"checkJs": true,
8+
"resolveJsonModule": true,
9+
"skipLibCheck": true,
10+
"noEmit": true,
11+
"importHelpers": false
12+
},
13+
"include": [
14+
"."
15+
]
16+
}

templates/module/package.json.tmpl

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"name": "{{.module}}",
3+
"version": "{{.version}}",
4+
"description": "{{.description}}",
5+
"keywords": [
6+
"widl",
7+
"codegen"
8+
],
9+
"engines": {
10+
"node": ">=8.5"
11+
},
12+
"main": "./dist/cjs/index.js",
13+
"module": "./dist/esm/index.js",
14+
"types": "./dist/types/index.d.ts",
15+
"browser": "./dist/standalone.js",
16+
"browser-min": "./dist/standalone.min.js",
17+
"exports": {
18+
".": "./dist/cjs/index.js",
19+
"./assemblyscript": "./dist/cjs/assemblyscript/index.js",
20+
"./go": "./dist/cjs/go/index.js",
21+
"./rust": "./dist/cjs/rust/index.js",
22+
"./tinygo": "./dist/cjs/tinygo/index.js",
23+
"./utils": "./dist/cjs/utils/index.js"
24+
},
25+
"files": [
26+
"templates",
27+
"dist",
28+
"README.md",
29+
"test",
30+
"src",
31+
"docs"
32+
],
33+
"sideEffects": false,
34+
"scripts": {
35+
"prebuild": "npm run clean",
36+
"build": "npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
37+
"build:esm": "tsc --module es2015 --outDir dist/esm",
38+
"build:cjs": "tsc --declaration --declarationMap --declarationDir dist/types ",
39+
"build:umd": "rollup --config config/rollup.config.js",
40+
"build:umd:min": "cd dist && uglifyjs --compress --mangle --source-map --comments --output standalone.min.js -- standalone.js",
41+
"watch": "tsc -w",
42+
"clean": "shx rm -rf dist",
43+
"docs": "typedoc --theme minimal --exclude \"**/src/**/__tests__/*.*\" --out docs src/",
44+
"test": "jest -c ./config/jest.config.js --passWithNoTests",
45+
"test:watch": "npm t -- --watch",
46+
"test:coverage": "npm t -- --coverage",
47+
"test:ci": "npm t -- --ci",
48+
"style": "npm run format -- --list-different && npm run lint",
49+
"style:fix": "npm run format:fix && npm run lint:fix",
50+
"format": "prettier \"src/**/*.{ts,tsx,js,jsx,css,scss,sass,less,md}\"",
51+
"format:fix": "npm run format -- --write",
52+
"lint": "eslint -c ./config/.eslintrc.json src --ext .ts",
53+
"lint:fix": "npm run lint -- --fix",
54+
"prerelease": "npm run build",
55+
"release": "standard-version",
56+
"release:github": "git push --no-verify --follow-tags origin master",
57+
"release:npm": "npm publish --access public",
58+
"release:preflight": "npm pack --dry-run"
59+
},
60+
"dependencies": {
61+
"@wapc/widl": "^0.0.6"
62+
},
63+
"devDependencies": {
64+
"@rollup/plugin-commonjs": "^17.1.0",
65+
"@rollup/plugin-node-resolve": "^11.2.0",
66+
"@types/jest": "23.3.10",
67+
"@typescript-eslint/eslint-plugin": "^4.22.0",
68+
"@typescript-eslint/parser": "^4.22.0",
69+
"eslint": "^7.22.0",
70+
"jest": "26.6.3",
71+
"jest-watch-typeahead": "^0.6.1",
72+
"prettier": "^2.2.1",
73+
"rollup": "2.41.3",
74+
"shx": "0.3.3",
75+
"standard-version": "4.4.0",
76+
"ts-jest": "26.5.3",
77+
"tslib": "^2.1.0",
78+
"typedoc": "0.20.32",
79+
"typescript": "4.1.3",
80+
"uglify-js": "^3.13.1",
81+
"webpack-config-utils": "2.3.1"
82+
}
83+
}

templates/module/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Module code here

templates/module/templates/.gitkeep

Whitespace-only changes.

templates/module/tsconfig.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "node",
4+
"module": "CommonJS",
5+
"target": "es2015",
6+
"lib": ["es2015"],
7+
"outDir": "dist/cjs",
8+
"baseUrl": ".",
9+
"paths": {
10+
"@wapc/widl": ["node_modules/@wapc/widl/dist/types"],
11+
"@wapc/widl/*": ["node_modules/@wapc/widl/dist/types/*"]
12+
},
13+
"strict": true,
14+
"esModuleInterop": true,
15+
"forceConsistentCasingInFileNames": true,
16+
"sourceMap": true,
17+
"stripInternal": true,
18+
"importHelpers": true,
19+
"plugins": [
20+
{
21+
"name": "typescript-tslint-plugin",
22+
"alwaysShowRuleFailuresAsWarnings": false
23+
}
24+
]
25+
},
26+
"include": ["./src"],
27+
"compileOnSave": false
28+
}

0 commit comments

Comments
 (0)