Compare commits

...

4 Commits

Author SHA1 Message Date
semantic-release-bot 7df2ed737b chore(release): 0.1.0-develop.1 [skip ci]
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/presetter-relay-plugin-preset/compare/v0.0.1...v0.1.0-develop.1) (2023-07-07)

### Features

* initial version ([3a8855a](3a8855abe2))
2023-07-07 04:36:34 +00:00
Derrick Hammer eee3a0df06
chore: update LICENSE 2023-07-07 00:35:08 -04:00
Derrick Hammer c9a68b2876
ci: setup 2023-07-07 00:33:29 -04:00
Derrick Hammer 3a8855abe2
feat: initial version 2023-07-07 00:28:07 -04:00
9 changed files with 19083 additions and 1 deletions

13
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
main:
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
secrets: inherit

5
.presetterrc.json Normal file
View File

@ -0,0 +1,5 @@
{
"preset": [
"@lumeweb/node-library-preset"
]
}

6
CHANGELOG.md Normal file
View File

@ -0,0 +1,6 @@
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/presetter-relay-plugin-preset/compare/v0.0.1...v0.1.0-develop.1) (2023-07-07)
### Features
* initial version ([3a8855a](https://git.lumeweb.com/LumeWeb/presetter-relay-plugin-preset/commit/3a8855abe2fdd41bcc95e404baa81a11123719c4))

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) <year> <copyright holders>
Copyright (c) 2023 Hammer TechnologiesLLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

18931
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

31
package.json Normal file
View File

@ -0,0 +1,31 @@
{
"name": "@lumeweb/presetter-relay-plugin-preset",
"version": "0.1.0-develop.1",
"type": "module",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/presetter-relay-plugin-preset.git"
},
"devDependencies": {
"@lumeweb/node-library-preset": "^0.2.7",
"presetter": "^4.0.1"
},
"readme": "ERROR: No README data found!",
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"dependencies": {
"read-pkg": "^8.0.0",
"semantic-release": "^21.0.7"
},
"publishConfig": {
"access": "public"
},
"files": [
"lib",
"templates"
]
}

87
src/index.ts Normal file
View File

@ -0,0 +1,87 @@
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import {
loadFile,
template,
PresetAsset,
PresetContext,
resolveDirective,
} from "presetter";
import { readPackage } from "read-pkg";
const DIR = fileURLToPath(dirname(import.meta.url));
// paths to the template directory
const TEMPLATES = resolve(DIR, "..", "templates");
/** List of configurable variables */
export type Variable = {
/** the directory containing all source code (default: source) */
source: string;
/** the directory containing all the compiled files (default: lib) */
output: string;
buildSource: string;
};
export const DEFAULT_VARIABLE: Variable = {
source: "build",
output: "lib",
buildSource: "src",
};
function buildOptions(context: PresetContext) {
const opts = context.custom.config?.esbuild as any;
if (!opts) {
throw new Error("esbuild options missing!");
}
return { esbuildOptions: resolveDirective(opts, context).stringifiedConfig };
}
/**
* get the list of templates provided by this preset
* @returns list of preset templates
*/
export default async function (context: PresetContext): Promise<PresetAsset> {
let name: string = context.custom.config?.pluginName as unknown as string;
if (!name) {
const pkg = await readPackage();
name = pkg.name.split("plugin-").pop() as string;
}
return {
extends: ["presetter-preset-strict"],
template: {
"build.js": (context) => {
const content = loadFile(resolve(TEMPLATES, "build.js"), "text");
const variable = buildOptions(context);
return template(content, variable);
},
},
scripts: resolve(TEMPLATES, "scripts.yaml"),
noSymlinks: ["build.js"],
supplementaryConfig: {
"gitignore": ["build.js"],
"tsconfig": {
compilerOptions: {
moduleResolution: "nodenext",
},
},
"tsconfig.build": {
include: ["{buildSource}"],
compilerOptions: {
outDir: "{source}",
},
},
"esbuild": {
entryPoints: ["{source}/index.ts"],
outfile: `{output}/${name}.js`,
format: "cjs",
bundle: true,
platform: "node",
},
},
};
}

3
templates/build.js Normal file
View File

@ -0,0 +1,3 @@
import esbuild from "esbuild";
esbuild.buildSync({esbuildOptions});

6
templates/scripts.yaml Normal file
View File

@ -0,0 +1,6 @@
# replace the `prepare` template from presetter-preset
# so that the build procedure will not be triggered upon package installation
build: cross-env NODE_ENV=production run-s clean build:typescript:* build:esbuild
build:esbuild: node build.js
develop: cross-env NODE_ENV=development run-s "build:esbuild -- --watch {@}" --
clean:buildOutput: shx rm -rf {source}