Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"googleapis": "^109.0.1",
"heroku-client": "^3.1.0",
"joi": "^17.13.3",
"js-yaml": "^3.13.1",
"ora": "^5.1.2",
"queue": "^6.0.2"
"queue": "^6.0.2",
"yaml": "^2.8.1"
},
"devDependencies": {
"@octokit/openapi-types": "^27.0.0",
Expand All @@ -45,7 +45,6 @@
"@types/fs-extra": "^7.0.0",
"@types/heroku-client": "^3.1.3",
"@types/joi": "^14.3.3",
"@types/js-yaml": "^3.12.1",
"@types/node": "^20.14.12",
"husky": "^8.0.0",
"lint-staged": "^12.4.1",
Expand Down
6 changes: 3 additions & 3 deletions src/permissions/generate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chalk from 'chalk';
import ora from 'ora';
import yml from 'js-yaml';
import YAML from 'yaml';

import { PERMISSIONS_FILE_ORG } from '../constants.js';
import { getOctokit } from '../octokit.js';
Expand Down Expand Up @@ -122,8 +122,8 @@ async function main(spinner: ora.Ora) {
permissions.organizations[0].repositories.sort((a, b) => a.name.localeCompare(b.name));
spinner.succeed('Generated configuration');
console.log(
yml.dump(permissions, {
sortKeys: true,
YAML.stringify(permissions, {
sortMapEntries: true,
}),
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/permissions/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import crypto from 'crypto';
import fs from 'fs-extra';
import Joi from 'joi';
import yml from 'js-yaml';
import YAML from 'yaml';
import _queue from 'queue';

import { graphyOctokit, getOctokit } from '../octokit.js';
Expand Down Expand Up @@ -45,11 +45,11 @@ console.warn('Dry Run?:', chalk[IS_DRY_RUN ? 'green' : 'red'](`${IS_DRY_RUN}`));

const loadCurrentConfig = async () => {
if (fs.existsSync('config.yml'))
return yml.safeLoad(fs.readFileSync('config.yml', 'utf8')) as PermissionsConfig;
return YAML.parse(fs.readFileSync('config.yml', 'utf8')) as PermissionsConfig;
if (fs.existsSync('config.yaml'))
return yml.safeLoad(fs.readFileSync('config.yaml', 'utf8')) as PermissionsConfig;
return YAML.parse(fs.readFileSync('config.yaml', 'utf8')) as PermissionsConfig;
if (PERMISSIONS_FILE_LOCAL_PATH && fs.existsSync(PERMISSIONS_FILE_LOCAL_PATH)) {
return yml.safeLoad(fs.readFileSync(PERMISSIONS_FILE_LOCAL_PATH, 'utf8')) as PermissionsConfig;
return YAML.parse(fs.readFileSync(PERMISSIONS_FILE_LOCAL_PATH, 'utf8')) as PermissionsConfig;
}
if (!PERMISSIONS_FILE_ORG) {
throw new Error('Missing PERMISSIONS_FILE_ORG env var');
Expand All @@ -64,7 +64,7 @@ const loadCurrentConfig = async () => {
});
if (Array.isArray(contents.data)) throw new Error('Invalid config file');

return yml.safeLoad(
return YAML.parse(
// @ts-ignore - Octokit fails to type properties of ReposGetContentsResponse correctly.
Buffer.from(contents.data.content || '', contents.data.encoding as any).toString('utf8'),
) as PermissionsConfig;
Expand Down
57 changes: 10 additions & 47 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ __metadata:
"@types/fs-extra": "npm:^7.0.0"
"@types/heroku-client": "npm:^3.1.3"
"@types/joi": "npm:^14.3.3"
"@types/js-yaml": "npm:^3.12.1"
"@types/node": "npm:^20.14.12"
"@vitest/utils": "npm:^4.0.6"
ansi-to-svg: "npm:^1.4.3"
Expand All @@ -47,12 +46,12 @@ __metadata:
heroku-client: "npm:^3.1.0"
husky: "npm:^8.0.0"
joi: "npm:^17.13.3"
js-yaml: "npm:^3.13.1"
lint-staged: "npm:^12.4.1"
ora: "npm:^5.1.2"
prettier: "npm:^2.7.1"
queue: "npm:^6.0.2"
typescript: "npm:^5.5.0"
yaml: "npm:^2.8.1"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -522,13 +521,6 @@ __metadata:
languageName: node
linkType: hard

"@types/js-yaml@npm:^3.12.1":
version: 3.12.1
resolution: "@types/js-yaml@npm:3.12.1"
checksum: 10c0/c6b8efc72ecf3e2e77ce6c5d9453b2a4798f9b97fefae76dfa32f4215fde25edbc7a9bba4bf20af05d764bd4212b08f61c614a65a858f640db069fbc02dfeb17
languageName: node
linkType: hard

"@types/mime@npm:*":
version: 2.0.1
resolution: "@types/mime@npm:2.0.1"
Expand Down Expand Up @@ -698,15 +690,6 @@ __metadata:
languageName: node
linkType: hard

"argparse@npm:^1.0.7":
version: 1.0.10
resolution: "argparse@npm:1.0.10"
dependencies:
sprintf-js: "npm:~1.0.2"
checksum: 10c0/b2972c5c23c63df66bca144dbc65d180efa74f25f8fd9b7d9a0a6c88ae839db32df3d54770dcb6460cf840d232b60695d1a6b1053f599d84e73f7437087712de
languageName: node
linkType: hard

"array-flatten@npm:1.1.1":
version: 1.1.1
resolution: "array-flatten@npm:1.1.1"
Expand Down Expand Up @@ -1211,16 +1194,6 @@ __metadata:
languageName: node
linkType: hard

"esprima@npm:^4.0.0":
version: 4.0.1
resolution: "esprima@npm:4.0.1"
bin:
esparse: ./bin/esparse.js
esvalidate: ./bin/esvalidate.js
checksum: 10c0/ad4bab9ead0808cf56501750fd9d3fb276f6b105f987707d059005d57e182d18a7c9ec7f3a01794ebddcca676773e42ca48a32d67a250c9d35e009ca613caba3
languageName: node
linkType: hard

"etag@npm:~1.8.1":
version: 1.8.1
resolution: "etag@npm:1.8.1"
Expand Down Expand Up @@ -1782,18 +1755,6 @@ __metadata:
languageName: node
linkType: hard

"js-yaml@npm:^3.13.1":
version: 3.13.1
resolution: "js-yaml@npm:3.13.1"
dependencies:
argparse: "npm:^1.0.7"
esprima: "npm:^4.0.0"
bin:
js-yaml: bin/js-yaml.js
checksum: 10c0/6a4f78b998d2eb58964cc5e051c031865bf292dc3c156a8057cf468d9e60a8739f4e8f607a267e97f09eb8d08263b8262df57eddb16b920ec5a04a259c3b4960
languageName: node
linkType: hard

"json-bigint@npm:^1.0.0":
version: 1.0.0
resolution: "json-bigint@npm:1.0.0"
Expand Down Expand Up @@ -2467,13 +2428,6 @@ __metadata:
languageName: node
linkType: hard

"sprintf-js@npm:~1.0.2":
version: 1.0.3
resolution: "sprintf-js@npm:1.0.3"
checksum: 10c0/ecadcfe4c771890140da5023d43e190b7566d9cf8b2d238600f31bec0fc653f328da4450eb04bd59a431771a8e9cc0e118f0aa3974b683a4981b4e07abc2a5bb
languageName: node
linkType: hard

"statuses@npm:2.0.1":
version: 2.0.1
resolution: "statuses@npm:2.0.1"
Expand Down Expand Up @@ -2838,3 +2792,12 @@ __metadata:
checksum: 10c0/5c28b9eb7adc46544f28d9a8d20c5b3cb1215a886609a2fd41f51628d8aaa5878ccd628b755dbcd29f6bb4921bd04ffbc6dcc370689bb96e594e2f9813d2605f
languageName: node
linkType: hard

"yaml@npm:^2.8.1":
version: 2.8.1
resolution: "yaml@npm:2.8.1"
bin:
yaml: bin.mjs
checksum: 10c0/7c587be00d9303d2ae1566e03bc5bc7fe978ba0d9bf39cc418c3139d37929dfcb93a230d9749f2cb578b6aa5d9ebebc322415e4b653cb83acd8bc0bc321707f3
languageName: node
linkType: hard