takker用UserScriptのbundle設定
一つずつCLIでcommandを叩くのが面倒なので、各project用UserScriptを一度にbundleしてjson fileにできるscriptを新しく作った
code:sh
code:build.ts
import {run} from '../UserScriptをbundleするDeno_script/script.ts';
bundleする
code:build.ts
for (const fileName of fileNames) {
const {outputFiles} = await run(
https://scrapbox.io/api/code/takker/takker用UserScriptのbundle設定/${fileName}.js,
{
},
{
external: [
'/api/code/takker-memex/GYAZO_ACCESS_TOKEN/auth.js',
'/api/code/takker-memex/Google_API_for_Scrapbox/script.js',
'/api/code/takker-memex/takkerのGoogle_Calendar/script.js',
],
charset: 'utf8',
bundle: true,
minify: true,
write: false, // 標準出力やfileにbundleしたコードを出力しない
sourcemap: 'inline',
}
);
}
code:build.ts
let json: {pages: {title: string; lines: string[];}[];} = {pages: []};
for (const key in codes) {
const page = {
title: for-${key},
lines: [
for-${key},
[/${key}]で使うUserScript,
'',
'code:script.js',
...codeskey.split('\n').map(line => ${line}), ],
};
json.pages.push(page);
}
await Deno.writeTextFile('import.json', JSON.stringify(json));
code:takker-memex.js
import '../import/common.js';
import '../import/takker-memex.js';
code:sh
code:takker.js
import '../import/common.js';
import '../import/takker.js';
code:sh
共通
code:any-project.js
import '../import/common.js';
code:sh
まとめて一つのjsonに入れられるようにした
code:sh
code:make-json.ts
type Page = {title: string; lines: string[];};
const {_: projects} = parse(Deno.args);
const json: {pages: Page[]} = {pages: []};
for (const project of projects) {
const script = await Deno.readTextFile(${project}.min.js);
const page = {
title: for-${project},
lines: [
for-${project},
[/${project}]で使うUserScript,
'',
'code:script.js',
...script.split('\n').map(line => ${line}),
],
};
json.pages.push(page);
}
await Deno.writeTextFile('import.json', JSON.stringify(json));