refactord paths.ts
This commit is contained in:
29
lib/build.js
29
lib/build.js
@@ -5,17 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const esbuild_1 = require("esbuild");
|
const esbuild_1 = require("esbuild");
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
const paths_1 = require("./paths");
|
|
||||||
const readmeta_1 = __importDefault(require("./readmeta"));
|
const readmeta_1 = __importDefault(require("./readmeta"));
|
||||||
const prettier_1 = require("prettier");
|
const prettier_1 = require("prettier");
|
||||||
const main_1 = require("./main");
|
const main_1 = require("./main");
|
||||||
function runBuild(name, watchCallback) {
|
function runBuild(name, watchCallback) {
|
||||||
//read meta file
|
//read meta file
|
||||||
let { meta, metaString } = (0, readmeta_1.default)(name);
|
let { meta, metaString } = (0, readmeta_1.default)(name);
|
||||||
let pathDist = (0, paths_1.DistPath)(name);
|
let paths = main_1.AllPaths.script(name);
|
||||||
let result = runEsbuild({
|
let result = runEsbuild({
|
||||||
entryPoints: [(0, paths_1.ScriptPath)(name).main],
|
entryPoints: [paths.main],
|
||||||
outfile: pathDist,
|
outfile: paths.dist,
|
||||||
target: 'esnext',
|
target: 'esnext',
|
||||||
platform: 'node',
|
platform: 'node',
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
@@ -94,14 +93,13 @@ function getResult(error, result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function clearFilenameComments(content) {
|
function clearFilenameComments(content) {
|
||||||
let regexp = new RegExp(`//\\s*${paths_1.ScriptBase}/.*(?:\\n|$)`, 'g');
|
let regexp = new RegExp(`//\\s*${main_1.AllPaths.base.script}/.*(?:\\n|$)`, 'g');
|
||||||
return content.replace(regexp, '');
|
return content.replace(regexp, '');
|
||||||
}
|
}
|
||||||
function postBuild(name, result, metaString) {
|
function postBuild(name, result, metaString) {
|
||||||
let error = null;
|
let error = null;
|
||||||
let path = (0, paths_1.ScriptPath)(name);
|
let paths = main_1.AllPaths.script(name);
|
||||||
let pathDist = (0, paths_1.DistPath)(name);
|
let PrettierConfig = prettier_1.resolveConfig.sync(paths.dir) || {};
|
||||||
let PrettierConfig = prettier_1.resolveConfig.sync(path.dir) || {};
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
console.error(name, result.errorRaw || result.error);
|
console.error(name, result.errorRaw || result.error);
|
||||||
error = result.error;
|
error = result.error;
|
||||||
@@ -114,7 +112,7 @@ function postBuild(name, result, metaString) {
|
|||||||
parser: 'babel',
|
parser: 'babel',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
(0, fs_1.writeFileSync)(pathDist, content);
|
(0, fs_1.writeFileSync)(paths.dist, content);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.error(name, 'No output');
|
console.error(name, 'No output');
|
||||||
@@ -123,17 +121,16 @@ function postBuild(name, result, metaString) {
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
function doErrorFile(name, error) {
|
function doErrorFile(name, error) {
|
||||||
let path = (0, paths_1.ScriptPath)(name);
|
let paths = main_1.AllPaths.script(name);
|
||||||
let outfile = (0, paths_1.DistPath)(name);
|
|
||||||
let content = `${new Date().toISOString()}\n\n${error}`;
|
let content = `${new Date().toISOString()}\n\n${error}`;
|
||||||
if (error !== null) {
|
if (error !== null) {
|
||||||
(0, fs_1.writeFileSync)(path.error, content);
|
(0, fs_1.writeFileSync)(paths.error, content);
|
||||||
if ((0, fs_1.existsSync)(outfile)) {
|
if ((0, fs_1.existsSync)(paths.dist)) {
|
||||||
(0, fs_1.unlinkSync)(outfile);
|
(0, fs_1.unlinkSync)(paths.dist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((0, fs_1.existsSync)(path.error)) {
|
else if ((0, fs_1.existsSync)(paths.error)) {
|
||||||
(0, fs_1.unlinkSync)(path.error);
|
(0, fs_1.unlinkSync)(paths.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=build.js.map
|
//# sourceMappingURL=build.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;;;AAAA,qCAA4E;AAC5E,2BAA0D;AAC1D,mCAA0D;AAE1D,0DAAiC;AACjC,uCAAgD;AAChD,iCAAgC;AAOhC,SAAwB,QAAQ,CAC5B,IAAY,EACZ,aAAyC;IAEzC,gBAAgB;IAChB,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAA;IACzC,IAAI,QAAQ,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAA;IAE7B,IAAI,MAAM,GAAG,UAAU,CACnB;QACI,WAAW,EAAE,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QACpC,OAAO,EAAE,QAAQ;QAEjB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,KAAK;QAEb,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,cAAO,CAAC,MAAM;QAEtB,MAAM,EAAE;YACJ,cAAc,EAAE,IAAI,IAAI,CAAC,IAAI,GAAG;YAChC,mBAAmB,EAAE,IAAI,IAAI,CAAC,SAAS,GAAG;YAC1C,iBAAiB,EAAE,IAAI,IAAI,CAAC,OAAO,GAAG;YAEtC,qBAAqB,EAAE,IAAI,IAAI,CAAC,WAAW,GAAG;YAC9C,oBAAoB,EAAE,IAAI,IAAI,CAAC,UAAU,GAAG;YAC5C,qBAAqB,EAAE,IAAI,IAAI,CAAC,WAAW,GAAG;SACjD;KACJ,EACD,MAAM,CAAC,EAAE;QACL,IAAI,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAA;QAC/C,aAAa,CAAC;YACV,IAAI;YACJ,KAAK;SACR,CAAC,CAAA;IACN,C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,CAAC,KAAK,CAAC,CAAA;KAC1B;AACL,CAAC"}
|
||||||
22
lib/main.js
22
lib/main.js
@@ -26,20 +26,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.CLIArgs = void 0;
|
exports.AllPaths = exports.CLIArgs = void 0;
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
const command_line_args_1 = __importDefault(require("command-line-args"));
|
const command_line_args_1 = __importDefault(require("command-line-args"));
|
||||||
const paths_1 = require("./paths");
|
|
||||||
const readmefile_1 = require("./readmefile");
|
const readmefile_1 = require("./readmefile");
|
||||||
const build_1 = __importDefault(require("./build"));
|
const build_1 = __importDefault(require("./build"));
|
||||||
const Path = __importStar(require("path"));
|
const Path = __importStar(require("path"));
|
||||||
|
const paths_1 = __importDefault(require("./paths"));
|
||||||
exports.CLIArgs = (0, command_line_args_1.default)([
|
exports.CLIArgs = (0, command_line_args_1.default)([
|
||||||
{ name: 'watch', alias: 'w', type: Boolean, defaultValue: false },
|
{ name: 'watch', alias: 'w', type: Boolean, defaultValue: false },
|
||||||
{ name: 'minify', alias: 'm', type: Boolean, defaultValue: false },
|
{ name: 'minify', alias: 'm', type: Boolean, defaultValue: false },
|
||||||
{ name: 'prettier', alias: 'p', type: Boolean, defaultValue: false },
|
{ name: 'prettier', alias: 'p', type: Boolean, defaultValue: false },
|
||||||
{ name: 'srccomment', alias: 's', type: Boolean, defaultValue: false },
|
{ name: 'srccomment', alias: 's', type: Boolean, defaultValue: false },
|
||||||
{ name: 'help', alias: 'h', type: Boolean, defaultValue: false },
|
{ name: 'baseurl', alias: 'bu', type: String, defaultValue: '' },
|
||||||
|
{ name: 'remotebranch', alias: 'rb', type: String, defaultValue: 'main' },
|
||||||
|
{ name: 'scriptsdir', alias: 'sd', type: String, defaultValue: 'scripts' },
|
||||||
|
{ name: 'distdir', alias: 'dd', type: String, defaultValue: 'dist' },
|
||||||
|
{ name: 'help', alias: 'h', type: Boolean },
|
||||||
]);
|
]);
|
||||||
|
exports.AllPaths = (0, paths_1.default)({
|
||||||
|
baseURL: exports.CLIArgs.baseurl || '',
|
||||||
|
remoteBranch: exports.CLIArgs.remotebranch || 'main',
|
||||||
|
scriptBase: exports.CLIArgs.scriptpath || 'scripts',
|
||||||
|
distBase: exports.CLIArgs.distpath || 'dist',
|
||||||
|
});
|
||||||
if (exports.CLIArgs.help) {
|
if (exports.CLIArgs.help) {
|
||||||
let command = '<command>';
|
let command = '<command>';
|
||||||
if (process.argv.length > 0) {
|
if (process.argv.length > 0) {
|
||||||
@@ -77,12 +87,12 @@ if (!(0, fs_1.existsSync)('package.json') || !(0, fs_1.lstatSync)('package.json'
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
//delete compiled scripts
|
//delete compiled scripts
|
||||||
(0, fs_1.readdirSync)(paths_1.DistBase).forEach(file => (0, fs_1.unlinkSync)(`${paths_1.DistBase}/${file}`));
|
(0, fs_1.readdirSync)(exports.AllPaths.base.dist).forEach(file => (0, fs_1.unlinkSync)(`${exports.AllPaths.base.dist}/${file}`));
|
||||||
//compile scripts
|
//compile scripts
|
||||||
let scripts = (0, fs_1.readdirSync)(paths_1.ScriptBase);
|
let scripts = (0, fs_1.readdirSync)(exports.AllPaths.base.script);
|
||||||
let scriptMeta = [];
|
let scriptMeta = [];
|
||||||
for (let name of scripts) {
|
for (let name of scripts) {
|
||||||
let path = (0, paths_1.ScriptPath)(name);
|
let path = exports.AllPaths.script(name);
|
||||||
if (!name.endsWith('_') &&
|
if (!name.endsWith('_') &&
|
||||||
(0, fs_1.existsSync)(path.dir) &&
|
(0, fs_1.existsSync)(path.dir) &&
|
||||||
(0, fs_1.lstatSync)(path.dir).isDirectory() &&
|
(0, fs_1.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rB,IAAA,cAAS,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAC/B;QACE,IAAI,EAAE,GAAG,UAAU,CAAC,MAAM,CAAA;QAE1B,SAAS,MAAM,CAAC,MAAgB;YAC5B,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAC/C,UAAU,CAAC,EAAE,CAAC,GAAG,MAAM,CAAA;YACvB,IAAA,6BAAgB,EAAC,UAAU,CAAC,CAAA;QAChC,CAAC;QAED,IAAI,MAAM,GAAG,IAAA,eAAQ,EAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACnC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAEtC,UAAU,CAAC,EAAE,CAAC,GAAG,MAAM,CAAA;KAC1B;CACJ;AAED,IAAA,6BAAgB,EAAC,UAAU,CAAC,CAAA;AAE5B,OAAO,CAAC,GAAG,CACP,yBAAyB,eAAO,CAAC,KAAK,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5E,CAAA"}
|
||||||
39
lib/paths.js
39
lib/paths.js
@@ -1,20 +1,25 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.DistPath = exports.ScriptPath = exports.FileUrl = exports.SupportUrl = exports.DistBase = exports.ScriptBase = exports.RemoteBranch = exports.BaseUrl = void 0;
|
function getAllPaths({ baseURL, remoteBranch, scriptBase, distBase, }) {
|
||||||
exports.BaseUrl = `https://git.zomo.dev/zomo/browser-scripts`;
|
return {
|
||||||
exports.RemoteBranch = 'main';
|
base: {
|
||||||
exports.ScriptBase = 'scripts';
|
branch: remoteBranch,
|
||||||
exports.DistBase = 'dist';
|
script: scriptBase,
|
||||||
exports.SupportUrl = `${exports.BaseUrl}/issues`;
|
dist: distBase,
|
||||||
const FileUrl = (name) => `${exports.BaseUrl}/raw/branch/${exports.RemoteBranch}/${exports.DistBase}/${name}.user.js`;
|
},
|
||||||
exports.FileUrl = FileUrl;
|
url: {
|
||||||
const ScriptPath = (name) => ({
|
base: baseURL,
|
||||||
dir: `${exports.ScriptBase}/${name}`,
|
support: `${baseURL}/issues`,
|
||||||
main: `${exports.ScriptBase}/${name}/main.ts`,
|
},
|
||||||
meta: `${exports.ScriptBase}/${name}/meta.json`,
|
script: (name) => ({
|
||||||
error: `${exports.ScriptBase}/${name}/error.log`,
|
dir: `${scriptBase}/${name}`,
|
||||||
});
|
main: `${scriptBase}/${name}/main.ts`,
|
||||||
exports.ScriptPath = ScriptPath;
|
meta: `${scriptBase}/${name}/meta.json`,
|
||||||
const DistPath = (name) => `${exports.DistBase}/${name}.user.js`;
|
error: `${scriptBase}/${name}/error.log`,
|
||||||
exports.DistPath = DistPath;
|
dist: `${distBase}/${name}.user.js`,
|
||||||
|
url: `${baseURL}/raw/branch/${remoteBranch}/${distBase}/${name}.user.js`,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.default = getAllPaths;
|
||||||
//# sourceMappingURL=paths.js.map
|
//# sourceMappingURL=paths.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,2CAA2C,CAAA;AACrD,QAAA,YAAY,GAAG,MAAM,CAAA;AACrB,QAAA,UAAU,GAAG,SAAS,CAAA;AACtB,QAAA,QAAQ,GAAG,MAAM,CAAA;AAEjB,QAAA,UAAU,GAAG,GAAG,eAAO,SAAS,CAAA;AACtC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CACpC,GAAG,eAAO,eAAe,oBAAY,IAAI,gBAAQ,IAAI,IAAI,UAAU,CAAA;AAD1D,QAAA,OAAO,WACmD;AAQhE,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.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
const paths_1 = require("./paths");
|
const main_1 = require("./main");
|
||||||
function readMeta(name) {
|
function readMeta(name) {
|
||||||
|
let paths = main_1.AllPaths.script(name);
|
||||||
|
let urls = main_1.AllPaths.url;
|
||||||
var meta = {
|
var meta = {
|
||||||
name: name,
|
name: name,
|
||||||
namespace: 'zomo.dev',
|
namespace: 'zomo.dev',
|
||||||
@@ -17,12 +19,12 @@ function readMeta(name) {
|
|||||||
noframes: false,
|
noframes: false,
|
||||||
grant: '',
|
grant: '',
|
||||||
injectinto: '',
|
injectinto: '',
|
||||||
downloadURL: (0, paths_1.FileUrl)(name),
|
downloadURL: paths.url,
|
||||||
supportURL: paths_1.SupportUrl,
|
supportURL: urls.support,
|
||||||
homepageURL: paths_1.BaseUrl,
|
homepageURL: urls.base,
|
||||||
unwrap: false,
|
unwrap: false,
|
||||||
};
|
};
|
||||||
let metaPath = (0, paths_1.ScriptPath)(name).meta;
|
let metaPath = paths.meta;
|
||||||
if ((0, fs_1.existsSync)(metaPath) && (0, fs_1.lstatSync)(metaPath).isFile()) {
|
if ((0, fs_1.existsSync)(metaPath) && (0, fs_1.lstatSync)(metaPath).isFile()) {
|
||||||
try {
|
try {
|
||||||
let args = JSON.parse((0, fs_1.readFileSync)(metaPath).toString());
|
let args = JSON.parse((0, fs_1.readFileSync)(metaPath).toString());
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"readmeta.js","sourceRoot":"","sources":["../src/readmeta.ts"],"names":[],"mappings":";;AAAA,2BAAwD;AACxD,mCAAkE;AAYlE,SAAwB,QAAQ,CAAC,IAAY;IACzC,IAAI,IAAI,GAAuB;QAC3B,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,UAAU;QACrB,KAAK,EAAE,EAAE;QACT,YAAY,EAAE,EAAE;QAChB,OAAO,EAAE,OAA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AACL,CAAC;AAvGD,2BAuGC"}
|
||||||
@@ -29,7 +29,6 @@
|
|||||||
"match": {
|
"match": {
|
||||||
"description": "Define rules to decide whether a script should be executed",
|
"description": "Define rules to decide whether a script should be executed",
|
||||||
"type": ["string", "array"],
|
"type": ["string", "array"],
|
||||||
"minItems": 1,
|
|
||||||
"uniqueItems": true,
|
"uniqueItems": true,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@@ -38,7 +37,6 @@
|
|||||||
"excludematch": {
|
"excludematch": {
|
||||||
"description": "Define rules to decide whether a script should be executed",
|
"description": "Define rules to decide whether a script should be executed",
|
||||||
"type": ["string", "array"],
|
"type": ["string", "array"],
|
||||||
"minItems": 1,
|
|
||||||
"uniqueItems": true,
|
"uniqueItems": true,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@@ -68,7 +66,6 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"description": "Require another script to execute before the current one\n\nThe value is the URL to the required script, which may be relative to the URL the script is being installed from",
|
"description": "Require another script to execute before the current one\n\nThe value is the URL to the required script, which may be relative to the URL the script is being installed from",
|
||||||
"type": ["string", "array"],
|
"type": ["string", "array"],
|
||||||
"minItems": 1,
|
|
||||||
"uniqueItems": true,
|
"uniqueItems": true,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@@ -77,7 +74,6 @@
|
|||||||
"resource": {
|
"resource": {
|
||||||
"description": "Static resources that can be accessed in the script by GM_getResourceText and GM_getResourceURL\n\nThe value is composed of two parts, joined with one or more white spaces\n\nThe first part is the name of the resource, no white space is allowed in it\n\nThe second part is the URL to the resource, which may be relative to the URL the script is being installed from",
|
"description": "Static resources that can be accessed in the script by GM_getResourceText and GM_getResourceURL\n\nThe value is composed of two parts, joined with one or more white spaces\n\nThe first part is the name of the resource, no white space is allowed in it\n\nThe second part is the URL to the resource, which may be relative to the URL the script is being installed from",
|
||||||
"type": ["string", "array"],
|
"type": ["string", "array"],
|
||||||
"minItems": 1,
|
|
||||||
"uniqueItems": true,
|
"uniqueItems": true,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@@ -95,7 +91,6 @@
|
|||||||
"grant": {
|
"grant": {
|
||||||
"description": "Specify which special APIs should be granted and can be used when the script executes\n\nIf nothing is present, \"none\" is assumed\n\nAny GM_ or GM. function used, including window.close and window.focus",
|
"description": "Specify which special APIs should be granted and can be used when the script executes\n\nIf nothing is present, \"none\" is assumed\n\nAny GM_ or GM. function used, including window.close and window.focus",
|
||||||
"type": ["string", "array"],
|
"type": ["string", "array"],
|
||||||
"minItems": 1,
|
|
||||||
"uniqueItems": true,
|
"uniqueItems": true,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ builder for [browser-scripts](https://git.zomo.dev/zomo/browser-scripts)
|
|||||||
|
|
||||||
## Source File Structure
|
## Source File Structure
|
||||||
|
|
||||||
|
note: if `package.json` is not present, running the command is presumed to be a mistake and will refuse to run
|
||||||
|
|
||||||
```text
|
```text
|
||||||
Root
|
Root
|
||||||
├───<package.json/etc>
|
├───<package.json/etc>
|
||||||
|
|||||||
31
src/build.ts
31
src/build.ts
@@ -1,10 +1,9 @@
|
|||||||
import { buildSync, BuildFailure, BuildOptions, BuildResult } from 'esbuild'
|
import { buildSync, BuildFailure, BuildOptions, BuildResult } from 'esbuild'
|
||||||
import { existsSync, writeFileSync, unlinkSync } from 'fs'
|
import { existsSync, writeFileSync, unlinkSync } from 'fs'
|
||||||
import { DistPath, ScriptBase, ScriptPath } from './paths'
|
|
||||||
import { UserScriptMetaFull } from './types'
|
import { UserScriptMetaFull } from './types'
|
||||||
import readMeta from './readmeta'
|
import readMeta from './readmeta'
|
||||||
import { format, resolveConfig } from 'prettier'
|
import { format, resolveConfig } from 'prettier'
|
||||||
import { CLIArgs } from './main'
|
import { AllPaths, CLIArgs } from './main'
|
||||||
|
|
||||||
export default interface runBuild {
|
export default interface runBuild {
|
||||||
meta: UserScriptMetaFull
|
meta: UserScriptMetaFull
|
||||||
@@ -17,12 +16,12 @@ export default function runBuild(
|
|||||||
) {
|
) {
|
||||||
//read meta file
|
//read meta file
|
||||||
let { meta, metaString } = readMeta(name)
|
let { meta, metaString } = readMeta(name)
|
||||||
let pathDist = DistPath(name)
|
let paths = AllPaths.script(name)
|
||||||
|
|
||||||
let result = runEsbuild(
|
let result = runEsbuild(
|
||||||
{
|
{
|
||||||
entryPoints: [ScriptPath(name).main],
|
entryPoints: [paths.main],
|
||||||
outfile: pathDist,
|
outfile: paths.dist,
|
||||||
|
|
||||||
target: 'esnext',
|
target: 'esnext',
|
||||||
platform: 'node',
|
platform: 'node',
|
||||||
@@ -117,16 +116,15 @@ function getResult(error: BuildFailure | null, result: BuildResult | null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearFilenameComments(content: string): string {
|
function clearFilenameComments(content: string): string {
|
||||||
let regexp = new RegExp(`//\\s*${ScriptBase}/.*(?:\\n|$)`, 'g')
|
let regexp = new RegExp(`//\\s*${AllPaths.base.script}/.*(?:\\n|$)`, 'g')
|
||||||
return content.replace(regexp, '')
|
return content.replace(regexp, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
function postBuild(name: string, result: RunEsbuildResult, metaString: string) {
|
function postBuild(name: string, result: RunEsbuildResult, metaString: string) {
|
||||||
let error: string | null = null
|
let error: string | null = null
|
||||||
let path = ScriptPath(name)
|
let paths = AllPaths.script(name)
|
||||||
let pathDist = DistPath(name)
|
|
||||||
|
|
||||||
let PrettierConfig = resolveConfig.sync(path.dir) || {}
|
let PrettierConfig = resolveConfig.sync(paths.dir) || {}
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
console.error(name, result.errorRaw || result.error)
|
console.error(name, result.errorRaw || result.error)
|
||||||
@@ -139,7 +137,7 @@ function postBuild(name: string, result: RunEsbuildResult, metaString: string) {
|
|||||||
parser: 'babel',
|
parser: 'babel',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
writeFileSync(pathDist, content)
|
writeFileSync(paths.dist, content)
|
||||||
} else {
|
} else {
|
||||||
console.error(name, 'No output')
|
console.error(name, 'No output')
|
||||||
}
|
}
|
||||||
@@ -150,17 +148,16 @@ function postBuild(name: string, result: RunEsbuildResult, metaString: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function doErrorFile(name: string, error: string | null) {
|
function doErrorFile(name: string, error: string | null) {
|
||||||
let path = ScriptPath(name)
|
let paths = AllPaths.script(name)
|
||||||
let outfile = DistPath(name)
|
|
||||||
|
|
||||||
let content = `${new Date().toISOString()}\n\n${error}`
|
let content = `${new Date().toISOString()}\n\n${error}`
|
||||||
|
|
||||||
if (error !== null) {
|
if (error !== null) {
|
||||||
writeFileSync(path.error, content)
|
writeFileSync(paths.error, content)
|
||||||
if (existsSync(outfile)) {
|
if (existsSync(paths.dist)) {
|
||||||
unlinkSync(outfile)
|
unlinkSync(paths.dist)
|
||||||
}
|
}
|
||||||
} else if (existsSync(path.error)) {
|
} else if (existsSync(paths.error)) {
|
||||||
unlinkSync(path.error)
|
unlinkSync(paths.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/main.ts
33
src/main.ts
@@ -1,16 +1,22 @@
|
|||||||
import { existsSync, lstatSync, readdirSync, unlinkSync } from 'fs'
|
import { existsSync, lstatSync, readdirSync, unlinkSync } from 'fs'
|
||||||
import commandLineArgs from 'command-line-args'
|
import commandLineArgs from 'command-line-args'
|
||||||
import { DistBase, ScriptBase, ScriptPath } from './paths'
|
|
||||||
import { updateReadmeFile } from './readmefile'
|
import { updateReadmeFile } from './readmefile'
|
||||||
import runBuild from './build'
|
import runBuild from './build'
|
||||||
import * as Path from 'path'
|
import * as Path from 'path'
|
||||||
|
import getAllPaths from './paths'
|
||||||
|
|
||||||
export interface CLIArgsT {
|
export interface CLIArgsT {
|
||||||
watch: boolean
|
watch: boolean
|
||||||
minify: boolean
|
minify: boolean
|
||||||
prettier: boolean
|
prettier: boolean
|
||||||
srccomment: boolean
|
srccomment: boolean
|
||||||
help: boolean
|
|
||||||
|
baseurl?: string
|
||||||
|
remotebranch?: string
|
||||||
|
scriptpath?: string
|
||||||
|
distpath?: string
|
||||||
|
|
||||||
|
help?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CLIArgs = commandLineArgs([
|
export const CLIArgs = commandLineArgs([
|
||||||
@@ -18,9 +24,22 @@ export const CLIArgs = commandLineArgs([
|
|||||||
{ name: 'minify', alias: 'm', type: Boolean, defaultValue: false },
|
{ name: 'minify', alias: 'm', type: Boolean, defaultValue: false },
|
||||||
{ name: 'prettier', alias: 'p', type: Boolean, defaultValue: false },
|
{ name: 'prettier', alias: 'p', type: Boolean, defaultValue: false },
|
||||||
{ name: 'srccomment', alias: 's', type: Boolean, defaultValue: false },
|
{ name: 'srccomment', alias: 's', type: Boolean, defaultValue: false },
|
||||||
{ name: 'help', alias: 'h', type: Boolean, defaultValue: false },
|
|
||||||
|
{ name: 'baseurl', alias: 'bu', type: String, defaultValue: '' },
|
||||||
|
{ name: 'remotebranch', alias: 'rb', type: String, defaultValue: 'main' },
|
||||||
|
{ name: 'scriptsdir', alias: 'sd', type: String, defaultValue: 'scripts' },
|
||||||
|
{ name: 'distdir', alias: 'dd', type: String, defaultValue: 'dist' },
|
||||||
|
|
||||||
|
{ name: 'help', alias: 'h', type: Boolean },
|
||||||
]) as CLIArgsT
|
]) as CLIArgsT
|
||||||
|
|
||||||
|
export const AllPaths = getAllPaths({
|
||||||
|
baseURL: CLIArgs.baseurl || '',
|
||||||
|
remoteBranch: CLIArgs.remotebranch || 'main',
|
||||||
|
scriptBase: CLIArgs.scriptpath || 'scripts',
|
||||||
|
distBase: CLIArgs.distpath || 'dist',
|
||||||
|
})
|
||||||
|
|
||||||
if (CLIArgs.help) {
|
if (CLIArgs.help) {
|
||||||
let command = '<command>'
|
let command = '<command>'
|
||||||
if (process.argv.length > 0) {
|
if (process.argv.length > 0) {
|
||||||
@@ -61,14 +80,16 @@ if (!existsSync('package.json') || !lstatSync('package.json').isFile()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//delete compiled scripts
|
//delete compiled scripts
|
||||||
readdirSync(DistBase).forEach(file => unlinkSync(`${DistBase}/${file}`))
|
readdirSync(AllPaths.base.dist).forEach(file =>
|
||||||
|
unlinkSync(`${AllPaths.base.dist}/${file}`)
|
||||||
|
)
|
||||||
|
|
||||||
//compile scripts
|
//compile scripts
|
||||||
let scripts = readdirSync(ScriptBase)
|
let scripts = readdirSync(AllPaths.base.script)
|
||||||
let scriptMeta: runBuild[] = []
|
let scriptMeta: runBuild[] = []
|
||||||
|
|
||||||
for (let name of scripts) {
|
for (let name of scripts) {
|
||||||
let path = ScriptPath(name)
|
let path = AllPaths.script(name)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!name.endsWith('_') &&
|
!name.endsWith('_') &&
|
||||||
|
|||||||
51
src/paths.ts
51
src/paths.ts
@@ -1,23 +1,42 @@
|
|||||||
export const BaseUrl = `https://git.zomo.dev/zomo/browser-scripts`
|
|
||||||
export const RemoteBranch = 'main'
|
|
||||||
export const ScriptBase = 'scripts'
|
|
||||||
export const DistBase = 'dist'
|
|
||||||
|
|
||||||
export const SupportUrl = `${BaseUrl}/issues`
|
|
||||||
export const FileUrl = (name: string) =>
|
|
||||||
`${BaseUrl}/raw/branch/${RemoteBranch}/${DistBase}/${name}.user.js`
|
|
||||||
|
|
||||||
export interface ScriptPathT {
|
export interface ScriptPathT {
|
||||||
dir: `${string}/${string}`
|
dir: `${string}/${string}`
|
||||||
main: `${string}/${string}/main.ts`
|
main: `${string}/${string}/main.ts`
|
||||||
meta: `${string}/${string}/meta.json`
|
meta: `${string}/${string}/meta.json`
|
||||||
error: `${string}/${string}/error.log`
|
error: `${string}/${string}/error.log`
|
||||||
|
dist: `${string}/${string}.user.js`
|
||||||
|
url: `${string}/raw/branch/${string}/${string}/${string}.user.js`
|
||||||
}
|
}
|
||||||
export const ScriptPath = (name: string): ScriptPathT => ({
|
|
||||||
dir: `${ScriptBase}/${name}`,
|
|
||||||
main: `${ScriptBase}/${name}/main.ts`,
|
|
||||||
meta: `${ScriptBase}/${name}/meta.json`,
|
|
||||||
error: `${ScriptBase}/${name}/error.log`,
|
|
||||||
})
|
|
||||||
|
|
||||||
export const DistPath = (name: string) => `${DistBase}/${name}.user.js`
|
export interface getAllPathsOps {
|
||||||
|
baseURL: string
|
||||||
|
remoteBranch: string
|
||||||
|
scriptBase: string
|
||||||
|
distBase: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function getAllPaths({
|
||||||
|
baseURL,
|
||||||
|
remoteBranch,
|
||||||
|
scriptBase,
|
||||||
|
distBase,
|
||||||
|
}: getAllPathsOps) {
|
||||||
|
return {
|
||||||
|
base: {
|
||||||
|
branch: remoteBranch,
|
||||||
|
script: scriptBase,
|
||||||
|
dist: distBase,
|
||||||
|
},
|
||||||
|
url: {
|
||||||
|
base: baseURL,
|
||||||
|
support: `${baseURL}/issues`,
|
||||||
|
},
|
||||||
|
script: (name: string): ScriptPathT => ({
|
||||||
|
dir: `${scriptBase}/${name}`,
|
||||||
|
main: `${scriptBase}/${name}/main.ts`,
|
||||||
|
meta: `${scriptBase}/${name}/meta.json`,
|
||||||
|
error: `${scriptBase}/${name}/error.log`,
|
||||||
|
dist: `${distBase}/${name}.user.js`,
|
||||||
|
url: `${baseURL}/raw/branch/${remoteBranch}/${distBase}/${name}.user.js`,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { existsSync, lstatSync, readFileSync } from 'fs'
|
import { existsSync, lstatSync, readFileSync } from 'fs'
|
||||||
import { BaseUrl, FileUrl, ScriptPath, SupportUrl } from './paths'
|
import { AllPaths } from './main'
|
||||||
import {
|
import {
|
||||||
UserScriptMeta,
|
UserScriptMeta,
|
||||||
UserScriptMetaFull,
|
UserScriptMetaFull,
|
||||||
@@ -12,6 +12,9 @@ export default interface readMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function readMeta(name: string) {
|
export default function readMeta(name: string) {
|
||||||
|
let paths = AllPaths.script(name)
|
||||||
|
let urls = AllPaths.url
|
||||||
|
|
||||||
var meta: UserScriptMetaFull = {
|
var meta: UserScriptMetaFull = {
|
||||||
name: name,
|
name: name,
|
||||||
namespace: 'zomo.dev',
|
namespace: 'zomo.dev',
|
||||||
@@ -26,13 +29,13 @@ export default function readMeta(name: string) {
|
|||||||
noframes: false,
|
noframes: false,
|
||||||
grant: '',
|
grant: '',
|
||||||
injectinto: '',
|
injectinto: '',
|
||||||
downloadURL: FileUrl(name),
|
downloadURL: paths.url,
|
||||||
supportURL: SupportUrl,
|
supportURL: urls.support,
|
||||||
homepageURL: BaseUrl,
|
homepageURL: urls.base,
|
||||||
unwrap: false,
|
unwrap: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
let metaPath = ScriptPath(name).meta
|
let metaPath = paths.meta
|
||||||
|
|
||||||
if (existsSync(metaPath) && lstatSync(metaPath).isFile()) {
|
if (existsSync(metaPath) && lstatSync(metaPath).isFile()) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user