@evanpurkhiser/tooling-personal 1.29.0 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/assignees.js CHANGED
@@ -7,6 +7,7 @@ exports.selectAssignee = exports.AssigneeType = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const fast_merge_async_iterators_1 = __importDefault(require("fast-merge-async-iterators"));
9
9
  const graphql_request_1 = require("graphql-request");
10
+ const config_1 = require("./config");
10
11
  const fzf_1 = require("./fzf");
11
12
  const graphql_1 = require("./graphql");
12
13
  var AssigneeType;
@@ -76,6 +77,9 @@ async function* getAssignees(repo) {
76
77
  const items = !isOrganization
77
78
  ? userAssignees
78
79
  : fast_merge_async_iterators_1.default(userAssignees, teamAssignees);
80
+ const assigneeesToIgnore = config_1.config
81
+ .get('ignoreAssignees')
82
+ .map(value => new RegExp(value));
79
83
  for await (const result of items) {
80
84
  const assignees = isUser(result)
81
85
  ? result.repository.assignableUsers.nodes.map(user => ({
@@ -90,7 +94,9 @@ async function* getAssignees(repo) {
90
94
  slug: team.combinedSlug,
91
95
  name: team.name,
92
96
  }));
93
- yield* assignees;
97
+ // Remove assignees that are ignored
98
+ const filteredAssignees = assignees.filter(assignee => !assigneeesToIgnore.some(r => r.test(assignee.slug)));
99
+ yield* filteredAssignees;
94
100
  }
95
101
  }
96
102
  /**
package/dist/cmd/pr.js CHANGED
@@ -16,7 +16,7 @@ const utils_1 = require("../utils");
16
16
  function getCommits(to) {
17
17
  return simple_git_1.default().log({ from: 'HEAD', to });
18
18
  }
19
- async function pr() {
19
+ async function pr(argv) {
20
20
  const username = await utils_1.getEmailUsername();
21
21
  const repo = await utils_1.getRepoKey();
22
22
  const { head, origin } = await utils_1.getBranchNames();
@@ -148,6 +148,7 @@ async function pr() {
148
148
  baseRefName: defaultBranch,
149
149
  headRefName: branchName,
150
150
  repositoryId: repoId,
151
+ draft: argv.draft,
151
152
  title,
152
153
  body,
153
154
  });
package/dist/config.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.config = void 0;
7
+ const convict_1 = __importDefault(require("convict"));
8
+ const js_yaml_1 = __importDefault(require("js-yaml"));
9
+ const path_1 = require("path");
10
+ convict_1.default.addParser({ extension: ['yml', 'yaml'], parse: js_yaml_1.default.load });
11
+ const config = convict_1.default({
12
+ ignoreAssignees: {
13
+ doc: 'Assignee names / teams to ignore. Should be a regex expression.',
14
+ format: Array,
15
+ default: [],
16
+ },
17
+ });
18
+ exports.config = config;
19
+ const home = process.env.HOME;
20
+ const configDir = process.env.XDG_CONFIG_HOME || path_1.join(home, '.config');
21
+ config.loadFile(path_1.join(configDir, 'pt', 'config.yml'));
22
+ config.validate();
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ yargs_1.default(process.argv.slice(2))
18
18
  chalk_1.default.level = args.color ? 3 : 0;
19
19
  }
20
20
  }, true)
21
- .command('pr', 'Create and update PRs', pr_1.pr)
21
+ .command('pr', 'Create and update PRs', y => y.option('draft', { alias: 'd', boolean: true, desc: 'Create PR as a draft' }), pr_1.pr)
22
22
  .command('select-commit', 'Select a commit hash', select_commit_1.selectCommit)
23
23
  .demandCommand(1, '')
24
24
  .parse();
package/dist/utils.js CHANGED
@@ -5,10 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.branchFromMessage = exports.getAccessToken = exports.getBranchNames = exports.getRepoPath = exports.getEmailUsername = exports.getRepoKey = void 0;
7
7
  const git_url_parse_1 = __importDefault(require("git-url-parse"));
8
- const js_yaml_1 = __importDefault(require("js-yaml"));
9
8
  const simple_git_1 = __importDefault(require("simple-git"));
10
- const fs_1 = require("fs");
11
- const path_1 = __importDefault(require("path"));
9
+ const child_process_1 = require("child_process");
12
10
  /**
13
11
  * Get's the current repo information
14
12
  */
@@ -61,12 +59,15 @@ async function getBranchNames() {
61
59
  }
62
60
  exports.getBranchNames = getBranchNames;
63
61
  /**
64
- * Get's the GitHub Oauth token from the hub config
62
+ * Get's the GitHub Oauth token from the gh auth token command
65
63
  */
66
64
  function getAccessToken() {
67
- const hubFile = path_1.default.join(process.env.XDG_DATA_HOME ?? '~/.local/share', 'tooling-personal', 'auth.yml');
68
- const hubConfig = js_yaml_1.default.load(fs_1.readFileSync(hubFile).toString());
69
- return hubConfig['token'];
65
+ try {
66
+ return child_process_1.execSync('gh auth token').toString().trim();
67
+ }
68
+ catch {
69
+ throw new Error('Cannot get token from `gh auth token`');
70
+ }
70
71
  }
71
72
  exports.getAccessToken = getAccessToken;
72
73
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanpurkhiser/tooling-personal",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
4
4
  "description": "Evan Purkhiser's personal tooling",
5
5
  "repository": "https://github.com/evanpurkhiser/tooling-personal",
6
6
  "author": "Evan Purkhiser",
@@ -11,11 +11,13 @@
11
11
  ],
12
12
  "dependencies": {
13
13
  "@octokit/graphql-schema": "^10.54.0",
14
+ "@types/convict": "^6.1.3",
14
15
  "@types/git-url-parse": "^9.0.1",
15
16
  "@types/js-yaml": "^4.0.2",
16
17
  "@types/node": "^16.3.3",
17
18
  "@types/yargs": "^17.0.2",
18
19
  "chalk": "^4.1.1",
20
+ "convict": "^6.2.4",
19
21
  "fast-merge-async-iterators": "^1.0.5",
20
22
  "git-url-parse": "^11.5.0",
21
23
  "graphql": "^15.5.1",