import {run} from '../UserScriptをbundleするDeno_script/script.ts'; const fileNames = ['takker-memex', 'takker', 'any-project']; let codes: {[key: string]: string} = {}; for (const fileName of fileNames) { const {outputFiles} = await run( `https://scrapbox.io/api/code/takker/takker用UserScriptのbundle設定/${fileName}.js`, { '../date-fns.min.js/script.js': 'https://deno.land/x/date_fns@v2.15.0/index.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', } ); codes[fileName] = outputFiles?.[0]?.text ?? ''; } let json: {pages: {title: string; lines: string[];}[];} = {pages: []}; for (const key in codes) { const page = { title: `for-${key}`, lines: [ `for-${key}`, `[/${key}]で使うUserScript`, ' [UserScriptをbundleするDeno script]でbundleした', ' 設定ファイルは[takker用UserScriptのbundle設定]に置いてある', '', 'code:script.js', ...codes[key].split('\n').map(line => ` ${line}`), ], }; json.pages.push(page); } await Deno.writeTextFile('import.json', JSON.stringify(json));