-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
createPackageJSON.js
144 lines (134 loc) · 4.6 KB
/
createPackageJSON.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* eslint-disable no-undef */
import fs from "fs";
import path from "path";
import { Octokit } from "octokit";
/** Following constants should match /extension/constants.ts */
const scopes = ["Workspace", "Global"];
export const prefix = "mayank1513.trello-kanban.";
const pkg = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), "package.json"), "utf-8"));
if (process.env.TOKEN) {
// 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",
},
};
const tagName = `v${pkg.version}`;
const name = `Release ${tagName}`;
/** Create a release */
octokit.request("POST /repos/{owner}/{repo}/releases", {
...octoOptions,
tag_name: tagName,
target_commitish: "main",
name,
draft: false,
prerelease: false,
generate_release_notes: true,
});
}
const configs = {
[prefix + "Workspace.saveToFile"]: {
type: "string",
default: "Yes",
enum: ["Yes", "No"],
description: "Save workspace data to a file.",
},
[prefix + "Workspace.filePath"]: {
type: "string",
/** set to --ignored-- when user chooses "don't ask again" */
default: "",
description:
"The path of the file (relative to current workspace) to save the data to. Prefer saving this to workspace config.",
},
};
scopes.forEach((scope) => {
configs[prefix + scope + ".statusBar.alignment"] = {
type: "string",
default: "Left",
enum: ["Left", "Right", "None"],
description: "Show the Kanban button on the left or right side of your status bar, or nowhere.",
};
configs[prefix + scope + ".statusBar.priority"] = {
type: "number",
default: 100,
description: "Where the Kanban button should be in relation to other buttons. A higher value means further left.",
};
});
const packageJSON = {
name: pkg.name,
displayName: "Trello Kanban Board",
description: "Simple trello like kanban board for Visual Studio Code. Visually organize your ideas!",
version: pkg.version,
publisher: "mayank1513",
icon: "logo.png",
engines: {
vscode: "^1.75.0",
},
license: "MIT",
author: {
name: "Mayank Kumar Chaudhari",
url: "https://mayank-chaudhari.vercel.app/",
},
categories: ["Visualization", "Notebooks", "Other"],
repository: {
type: "git",
url: "https://github.com/mayank1513/vscode-extension-trello-kanban-board",
},
bugs: {
url: "https://github.com/mayank1513/vscode-extension-trello-kanban-board/issues",
},
main: "./index.js",
contributes: {
commands: scopes.map((scope) => ({
command: prefix + scope,
title: "TrelloKanban: " + scope,
})),
configuration: {
title: "Trello Kanban Board",
properties: configs,
},
},
activationEvents: ["onStartupFinished"],
sponsor: {
url: "https://github.com/sponsors/mayank1513",
},
keywords: pkg.keywords,
badges: [
{
description: "Test",
url: "https://github.com/mayank1513/vscode-extension-trello-kanban-board/actions/workflows/test.yml/badge.svg",
href: "https://github.com/mayank1513/vscode-extension-trello-kanban-board/actions/workflows/test.yml",
},
{
description: "Coverage",
url: "https://codecov.io/gh/mayank1513/vscode-extension-trello-kanban-board/graph/badge.svg",
href: "https://codecov.io/gh/mayank1513/vscode-extension-trello-kanban-board",
},
{
description: "Maintainability",
url: "https://api.codeclimate.com/v1/badges/ac44e4371dd3a274285e/maintainability",
href: "https://codeclimate.com/github/mayank1513/vscode-extension-trello-kanban-board/maintainability",
},
{
description: "PayPal Donate",
url: "https://img.shields.io/badge/paypal-donate-blue.svg",
href: "https://paypal.me/mayank1513",
},
],
};
fs.writeFileSync(path.resolve(process.cwd(), "dist", "package.json"), JSON.stringify(packageJSON, null, 2));
const readMe = fs.readFileSync(path.resolve(process.cwd(), "README.md"), "utf-8");
fs.writeFileSync(path.resolve(process.cwd(), "dist", "README.md"), readMe.replace(/.*\.svg.*/g, "")); // remove lines with .svg
fs.copyFileSync(path.resolve(process.cwd(), "LICENSE"), path.resolve(process.cwd(), "dist", "LICENSE"));
fs.copyFileSync(path.resolve(process.cwd(), "CHANGELOG.md"), path.resolve(process.cwd(), "dist", "CHANGELOG.md"));
try {
fs.unlinkSync(path.resolve(process.cwd(), "dist", "index.html"));
} catch {
// ignore - index.html may not exist when we are building only extension multiple times without building the frontend
}