Skip to content

Commit

Permalink
Merge branch 'main' into experimental-serverless-build
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoobes authored Jul 27, 2024
2 parents 6db6cf5 + d581142 commit b369fdc
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-deprecate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Use Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 17
registry-url: 'https://registry.npmjs.org/'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 17
registry-url: 'https://registry.npmjs.org'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 17

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 17
registry-url: 'https://registry.npmjs.org'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
bump-patch-for-minor-pre-major: true
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 17
registry-url: 'https://registry.npmjs.org'
Expand Down
6 changes: 4 additions & 2 deletions src/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export async function publish(commandDir: string | undefined, args: Partial<Publ

commandDir && console.info('Publishing with override path: ', commandDir);

const dotenvLocation = new URL('../node_modules/dotenv/config.js', rootPath),
esmLoader = new URL('../node_modules/@esbuild-kit/esm-loader/dist/index.js', rootPath);
const isBunOrPnpm = rootPath.pathname.includes('.bun') || rootPath.pathname.includes('.pnpm');

const dotenvLocation = new URL(`${isBunOrPnpm ? '../../' : '../'}node_modules/dotenv/config.js`, rootPath),
esmLoader = new URL(`${isBunOrPnpm ? '../../' : '../'}node_modules/@esbuild-kit/esm-loader/dist/index.js`, rootPath);

// We dynamically load the create-publish script in a child process so that we can pass the special
// loader flag to require typescript files
Expand Down
14 changes: 6 additions & 8 deletions src/create-publish.mts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ for await (const absPath of filePaths) {
commandModule = commandModule.default;
}

if (typeof config === 'function') {
config = config(absPath, commandModule);
}

if ((PUBLISHABLE & commandModule.type) != 0) {
// assign defaults
const filename = basename(absPath);
Expand All @@ -65,7 +61,10 @@ for await (const absPath of filePaths) {
commandModule.meta = {
absPath
}

commandModule.absPath = absPath;
if (typeof config === 'function') {
config = config(absPath, commandModule);
}
modules.push({ commandModule, config });
}
}
Expand Down Expand Up @@ -129,9 +128,9 @@ const makePublishData = ({ commandModule, config }: Record<string, Record<string
integration_types: (config?.integrationTypes ?? ['Guild']).map(
(s: string) => {
if(s === "Guild") {
return 0
return "0"
} else if (s == "User") {
return 1
return "1"
} else {
throw Error("IntegrationType is not one of Guild (0) or User (1)");
}
Expand Down Expand Up @@ -259,7 +258,6 @@ const remoteData = {
global: globalCommandsResponse,
...Object.fromEntries(guildCommandMapResponse),
};

await writeFile(resolve(cacheDir, 'command-data-remote.json'), JSON.stringify(remoteData, null, 4), 'utf8');

// TODO: add this in a verbose flag
Expand Down
10 changes: 5 additions & 5 deletions src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const baseURL = new URL('https://discord.com/api/v10/applications/');

const excludedKeys = new Set(['command', 'absPath']);

const publishablesIntoJson = (ps: PublishableModule[]) =>
JSON.stringify(
const publishablesIntoJson = (ps: PublishableModule[]) => {
const s = JSON.stringify(
ps.map((module) => module.data),
(key, value) => (excludedKeys.has(key) ? undefined : value),
4
);
(key, value) => (excludedKeys.has(key) ? undefined : value), 4);
return s;
}

export const create = async (token: string) => {
const headers = {
Expand Down

0 comments on commit b369fdc

Please sign in to comment.