-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
touchup.js
60 lines (53 loc) · 1.6 KB
/
touchup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"use strict";
import fs from "fs";
import path from "path";
const packageJson = JSON.parse(
fs.readFileSync(path.resolve(process.cwd(), "package.json"), "utf-8")
);
if (process.env.TOKEN) {
const { Octokit } = require("octokit");
// Octokit.js
// https://github.com/octokit/core.js#readme
const octokit = new Octokit({
auth: process.env.TOKEN,
});
const octoOptions = {
owner: process.env.OWNER,
repo: process.env.REPO,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
};
octokit
.request("GET /repos/{owner}/{repo}/topics", octoOptions)
.then(({ data }) => {
octoOptions.names = [
...new Set([...data.names, ...packageJson.keywords]),
];
if (octoOptions.names.length !== data.names.length)
octokit
.request("PUT /repos/{owner}/{repo}/topics", octoOptions)
.then(console.log) // eslint-disable-line no-console -- intentional debug log
.catch(console.error); // eslint-disable-line no-console -- intentional error log
});
}
delete packageJson.devDependencies;
delete packageJson.dependencies;
delete packageJson.scripts;
packageJson.main = "TagInput.umd.mjs";
packageJson.module = "TagInput.js";
packageJson.types = "TagInput.vue.d.ts";
const outDir = path.resolve(process.cwd(), "dist", "lib");
fs.writeFileSync(
path.resolve(outDir, "package.json"),
JSON.stringify(packageJson, null, 2)
);
fs.copyFileSync(
path.resolve(process.cwd(), "README.md"),
path.resolve(outDir, "README.md")
);
fs.rename(
path.resolve(outDir, "TagInput.umd.cjs"),
path.resolve(outDir, "TagInput.umd.mjs"),
() => {}
);