diff --git a/.github/workflows/discord.yml b/.github/workflows/discord.yml index 94e094b7..6e237c86 100644 --- a/.github/workflows/discord.yml +++ b/.github/workflows/discord.yml @@ -21,10 +21,16 @@ jobs: - run: npm i -g yarn - run: yarn install - run: yarn test - - name: Disord Notification - run: yarn discord + - name: Disord Notification Epics + run: yarn discord:epics env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} + DISCORD_CHANNEL_ID: ${{ secrets.DISCORD_CHANNEL_ID }} DISCORD_CHANNEL_ID_JA: ${{ secrets.DISCORD_CHANNEL_ID_JA }} + - name: Disord Notification LABO + run: yarn discord:labo + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DISCORD_TOKEN_LABO: ${{ secrets.DISCORD_TOKEN_LABO }} LABO_SKEET_CHANNEL_ID: ${{ secrets.LABO_SKEET_CHANNEL_ID }} diff --git a/dist/index.js b/dist/index.js index 55c873cf..f4c80e14 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,4 +1,3 @@ -#!/usr/bin/env node "use strict";var DMe=Object.create;var lc=Object.defineProperty;var AMe=Object.getOwnPropertyDescriptor;var FMe=Object.getOwnPropertyNames;var _Me=Object.getPrototypeOf,kMe=Object.prototype.hasOwnProperty;var MMe=(c,g,d)=>g in c?lc(c,g,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[g]=d;var b=(c,g)=>lc(c,"name",{value:g,configurable:!0});var L=(c,g)=>()=>(g||c((g={exports:{}}).exports,g),g.exports),RMe=(c,g)=>{for(var d in g)lc(c,d,{get:g[d],enumerable:!0})},SY=(c,g,d,p)=>{if(g&&typeof g=="object"||typeof g=="function")for(let h of FMe(g))!kMe.call(c,h)&&h!==d&&lc(c,h,{get:()=>g[h],enumerable:!(p=AMe(g,h))||p.enumerable});return c};var lt=(c,g,d)=>(d=c!=null?DMe(_Me(c)):{},SY(g||!c||!c.__esModule?lc(d,"default",{value:c,enumerable:!0}):d,c)),NMe=c=>SY(lc({},"__esModule",{value:!0}),c);var rv=(c,g,d)=>(MMe(c,typeof g!="symbol"?g+"":g,d),d);var jY=L((OQt,BMe)=>{BMe.exports={name:"dotenv",version:"16.0.3",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{require:"./lib/main.js",types:"./lib/main.d.ts",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard","lint-readme":"standard-markdown",pretest:"npm run lint && npm run dts-check",test:"tap tests/*.js --100 -Rspec",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^17.0.9",decache:"^4.6.1",dtslint:"^3.7.0",sinon:"^12.0.1",standard:"^16.0.4","standard-markdown":"^7.1.0","standard-version":"^9.3.2",tap:"^15.1.6",tar:"^6.1.11",typescript:"^4.5.4"},engines:{node:">=12"}}});var hF=L((PQt,nv)=>{var IMe=require("fs"),xY=require("path"),LMe=require("os"),JMe=jY(),qMe=JMe.version,UMe=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function VMe(c){let g={},d=c.toString();d=d.replace(/\r\n?/mg,` `);let p;for(;(p=UMe.exec(d))!=null;){let h=p[1],s=p[2]||"";s=s.trim();let a=s[0];s=s.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),a==='"'&&(s=s.replace(/\\n/g,` `),s=s.replace(/\\r/g,"\r")),g[h]=s}return g}b(VMe,"parse");function fF(c){console.log(`[dotenv@${qMe}][DEBUG] ${c}`)}b(fF,"_log");function GMe(c){return c[0]==="~"?xY.join(LMe.homedir(),c.slice(1)):c}b(GMe,"_resolveHome");function zMe(c){let g=xY.resolve(process.cwd(),".env"),d="utf8",p=!!(c&&c.debug),h=!!(c&&c.override);c&&(c.path!=null&&(g=GMe(c.path)),c.encoding!=null&&(d=c.encoding));try{let s=av.parse(IMe.readFileSync(g,{encoding:d}));return Object.keys(s).forEach(function(a){Object.prototype.hasOwnProperty.call(process.env,a)?(h===!0&&(process.env[a]=s[a]),p&&fF(h===!0?`"${a}" is already defined in \`process.env\` and WAS overwritten`:`"${a}" is already defined in \`process.env\` and was NOT overwritten`)):process.env[a]=s[a]}),{parsed:s}}catch(s){return p&&fF(`Failed to load ${g} ${s.message}`),{error:s}}}b(zMe,"config");var av={config:zMe,parse:VMe};nv.exports.config=av.config;nv.exports.parse=av.parse;nv.exports=av});var wh=L(yF=>{var jh=class extends Error{constructor(g,d,p){super(p),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=d,this.exitCode=g,this.nestedError=void 0}};b(jh,"CommanderError");var iv=class extends jh{constructor(g){super(1,"commander.invalidArgument",g),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};b(iv,"InvalidArgumentError");yF.CommanderError=jh;yF.InvalidArgumentError=iv});var uv=L(vF=>{var{InvalidArgumentError:HMe}=wh(),sv=class{constructor(g,d){switch(this.description=d||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,g[0]){case"<":this.required=!0,this._name=g.slice(1,-1);break;case"[":this.required=!1,this._name=g.slice(1,-1);break;default:this.required=!0,this._name=g;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(g,d){return d===this.defaultValue||!Array.isArray(d)?[g]:d.concat(g)}default(g,d){return this.defaultValue=g,this.defaultValueDescription=d,this}argParser(g){return this.parseArg=g,this}choices(g){return this.argChoices=g.slice(),this.parseArg=(d,p)=>{if(!this.argChoices.includes(d))throw new HMe(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(d,p):d},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};b(sv,"Argument");function QMe(c){let g=c.name()+(c.variadic===!0?"...":"");return c.required?"<"+g+">":"["+g+"]"}b(QMe,"humanReadableArgName");vF.Argument=sv;vF.humanReadableArgName=QMe});var TF=L(wY=>{var{humanReadableArgName:$Me}=uv(),pv=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(g){let d=g.commands.filter(p=>!p._hidden);if(g._hasImplicitHelpCommand()){let[,p,h]=g._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=g.createCommand(p).helpOption(!1);s.description(g._helpCommandDescription),h&&s.arguments(h),d.push(s)}return this.sortSubcommands&&d.sort((p,h)=>p.name().localeCompare(h.name())),d}compareOptions(g,d){let p=b(h=>h.short?h.short.replace(/^-/,""):h.long.replace(/^--/,""),"getSortKey");return p(g).localeCompare(p(d))}visibleOptions(g){let d=g.options.filter(s=>!s.hidden),p=g._hasHelpOption&&g._helpShortFlag&&!g._findOption(g._helpShortFlag),h=g._hasHelpOption&&!g._findOption(g._helpLongFlag);if(p||h){let s;p?h?s=g.createOption(g._helpFlags,g._helpDescription):s=g.createOption(g._helpShortFlag,g._helpDescription):s=g.createOption(g._helpLongFlag,g._helpDescription),d.push(s)}return this.sortOptions&&d.sort(this.compareOptions),d}visibleGlobalOptions(g){if(!this.showGlobalOptions)return[];let d=[];for(let p=g.parent;p;p=p.parent){let h=p.options.filter(s=>!s.hidden);d.push(...h)}return this.sortOptions&&d.sort(this.compareOptions),d}visibleArguments(g){return g._argsDescription&&g._args.forEach(d=>{d.description=d.description||g._argsDescription[d.name()]||""}),g._args.find(d=>d.description)?g._args:[]}subcommandTerm(g){let d=g._args.map(p=>$Me(p)).join(" ");return g._name+(g._aliases[0]?"|"+g._aliases[0]:"")+(g.options.length?" [options]":"")+(d?" "+d:"")}optionTerm(g){return g.flags}argumentTerm(g){return g.name()}longestSubcommandTermLength(g,d){return d.visibleCommands(g).reduce((p,h)=>Math.max(p,d.subcommandTerm(h).length),0)}longestOptionTermLength(g,d){return d.visibleOptions(g).reduce((p,h)=>Math.max(p,d.optionTerm(h).length),0)}longestGlobalOptionTermLength(g,d){return d.visibleGlobalOptions(g).reduce((p,h)=>Math.max(p,d.optionTerm(h).length),0)}longestArgumentTermLength(g,d){return d.visibleArguments(g).reduce((p,h)=>Math.max(p,d.argumentTerm(h).length),0)}commandUsage(g){let d=g._name;g._aliases[0]&&(d=d+"|"+g._aliases[0]);let p="";for(let h=g.parent;h;h=h.parent)p=h.name()+" "+p;return p+d+" "+g.usage()}commandDescription(g){return g.description()}subcommandDescription(g){return g.summary()||g.description()}optionDescription(g){let d=[];return g.argChoices&&d.push(`choices: ${g.argChoices.map(p=>JSON.stringify(p)).join(", ")}`),g.defaultValue!==void 0&&(g.required||g.optional||g.isBoolean()&&typeof g.defaultValue=="boolean")&&d.push(`default: ${g.defaultValueDescription||JSON.stringify(g.defaultValue)}`),g.presetArg!==void 0&&g.optional&&d.push(`preset: ${JSON.stringify(g.presetArg)}`),g.envVar!==void 0&&d.push(`env: ${g.envVar}`),d.length>0?`${g.description} (${d.join(", ")})`:g.description}argumentDescription(g){let d=[];if(g.argChoices&&d.push(`choices: ${g.argChoices.map(p=>JSON.stringify(p)).join(", ")}`),g.defaultValue!==void 0&&d.push(`default: ${g.defaultValueDescription||JSON.stringify(g.defaultValue)}`),d.length>0){let p=`(${d.join(", ")})`;return g.description?`${g.description} ${p}`:p}return g.description}formatHelp(g,d){let p=d.padWidth(g,d),h=d.helpWidth||80,s=2,a=2;function f(o,r){if(r){let u=`${o.padEnd(p+a)}${r}`;return d.wrap(u,h-s,p+a)}return o}b(f,"formatItem");function y(o){return o.join(` diff --git a/package.json b/package.json index 6da50db1..3a797759 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "start:dev": "npx ts-node build.ts && node ./dist/index.js", "start": "node dist/index.js", "skeet:skeet": "yarn --cwd ./functions/skeet dev", - "discord": "npx ts-node -r tsconfig-paths/register --transpile-only src/lib/runDiscordChangeLog.ts" + "discord:labo": "npx ts-node -r tsconfig-paths/register --transpile-only src/lib/runDiscordChangeLog.ts labo", + "discord:epics": "npx ts-node -r tsconfig-paths/register --transpile-only src/lib/runDiscordChangeLog.ts epics" }, "dependencies": { "@skeet-framework/ai": "1.7.4", @@ -75,4 +76,4 @@ "tsconfig-paths": "4.2.0", "typescript": "5.2.2" } -} \ No newline at end of file +} diff --git a/src/lib/runDiscordChangeLog.ts b/src/lib/runDiscordChangeLog.ts index 08841975..73938306 100644 --- a/src/lib/runDiscordChangeLog.ts +++ b/src/lib/runDiscordChangeLog.ts @@ -2,16 +2,25 @@ import { discordChangeLog } from '@skeet-framework/discord-utils' import { dotenv } from '@skeet-framework/utils' dotenv.config() -const REPO_NAME = 'elsoul/skeet-discord-utils' +const REPO_NAME = 'elsoul/skeet-cli' -const run = async () => { - const token = process.env.DISCORD_TOKEN || '' - const channelId = process.env.DISCORD_CHANNEL_ID || '' - const channelIdJA = process.env.DISCORD_CHANNEL_ID_JA || '' - const laboSkeetChannelId = process.env.LABO_SKEET_CHANNEL_ID || '' - await discordChangeLog(token, REPO_NAME, [channelId]) - await discordChangeLog(token, REPO_NAME, [channelIdJA], 'ja') - await discordChangeLog(token, REPO_NAME, [laboSkeetChannelId]) +const run = async (project: 'labo' | 'epics') => { + if (project === 'labo') { + console.log('labo') + const token = process.env.DISCORD_TOKEN_LABO || '' + const channelId = process.env.LABO_SKEET_CHANNEL_ID || '' + await discordChangeLog(token, REPO_NAME, [channelId]) + } else if (project === 'epics') { + console.log('epics') + const token = process.env.DISCORD_TOKEN || '' + const channelId = process.env.DISCORD_CHANNEL_ID || '' + const channelIdJA = process.env.DISCORD_CHANNEL_ID_JA || '' + await discordChangeLog(token, REPO_NAME, [channelId]) + await discordChangeLog(token, REPO_NAME, [channelIdJA], 'ja') + } else { + console.log('invalid project name') + } } -run() +const project = process.argv[2] as 'labo' | 'epics' +run(project)