@charcoal-ui/icons-cli 2.0.0-rc.1 → 2.0.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/GitHubClient.d.ts +2 -2
- package/dist/GitHubClient.d.ts.map +1 -1
- package/dist/GitlabClient.d.ts +2 -2
- package/dist/GitlabClient.d.ts.map +1 -1
- package/dist/getChangedFiles.d.ts +1 -2
- package/dist/getChangedFiles.d.ts.map +1 -1
- package/dist/index.cjs +16 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +16 -13
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +16 -13
- package/dist/index.module.js.map +1 -1
- package/package.json +2 -2
- package/src/GitHubClient.ts +7 -5
- package/src/GitlabClient.ts +7 -5
- package/src/getChangedFiles.ts +1 -3
- package/src/index.ts +6 -2
package/src/GitHubClient.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Octokit } from '@octokit/rest'
|
|
2
|
+
import path from 'path'
|
|
2
3
|
import { getChangedFiles } from './getChangedFiles'
|
|
3
4
|
|
|
4
5
|
type RefResponse = ReturnType<GithubClient['createBranch']> extends Promise<
|
|
@@ -23,11 +24,12 @@ export class GithubClient {
|
|
|
23
24
|
repoOwner: string,
|
|
24
25
|
repoName: string,
|
|
25
26
|
token: string,
|
|
26
|
-
defaultBranch: string
|
|
27
|
+
defaultBranch: string,
|
|
28
|
+
outputDir: string
|
|
27
29
|
) {
|
|
28
30
|
const client = new this(repoOwner, repoName, token, defaultBranch)
|
|
29
|
-
|
|
30
|
-
const diff = await client.createTreeFromDiff()
|
|
31
|
+
const outputDirFullPath = path.resolve(process.cwd(), outputDir)
|
|
32
|
+
const diff = await client.createTreeFromDiff(outputDirFullPath)
|
|
31
33
|
// eslint-disable-next-line no-console
|
|
32
34
|
console.log(`${diff.length} files are changed`)
|
|
33
35
|
if (diff.length === 0) {
|
|
@@ -67,10 +69,10 @@ export class GithubClient {
|
|
|
67
69
|
return `[icons-cli] Update icons ${this.now.toDateString()}`
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
async createTreeFromDiff(): Promise<TreeItem[]> {
|
|
72
|
+
async createTreeFromDiff(outputDir: string): Promise<TreeItem[]> {
|
|
71
73
|
const tree: TreeItem[] = []
|
|
72
74
|
|
|
73
|
-
for await (const file of getChangedFiles()) {
|
|
75
|
+
for await (const file of getChangedFiles(outputDir)) {
|
|
74
76
|
const item = {
|
|
75
77
|
path: file.relativePath,
|
|
76
78
|
// 100 はファイル 644 は実行不可なファイルであるという意味
|
package/src/GitlabClient.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CommitAction } from '@gitbeaker/core/dist/types/services/Commits'
|
|
2
2
|
import { Gitlab } from '@gitbeaker/node'
|
|
3
|
+
import path from 'path'
|
|
3
4
|
import { getChangedFiles } from './getChangedFiles'
|
|
4
5
|
|
|
5
6
|
type GitlabApi = InstanceType<typeof Gitlab>
|
|
@@ -12,11 +13,12 @@ export class GitlabClient {
|
|
|
12
13
|
host: string,
|
|
13
14
|
projectId: number,
|
|
14
15
|
privateToken: string,
|
|
15
|
-
defaultBranch: string
|
|
16
|
+
defaultBranch: string,
|
|
17
|
+
outputDir: string
|
|
16
18
|
) {
|
|
17
19
|
const client = new this(host, projectId, privateToken, defaultBranch)
|
|
18
|
-
|
|
19
|
-
const diff = await client.createActionsFromDiff()
|
|
20
|
+
const outputDirFullPath = path.resolve(process.cwd(), outputDir)
|
|
21
|
+
const diff = await client.createActionsFromDiff(outputDirFullPath)
|
|
20
22
|
// eslint-disable-next-line no-console
|
|
21
23
|
console.log(`${diff.length} files are changed`)
|
|
22
24
|
if (diff.length === 0) {
|
|
@@ -54,10 +56,10 @@ export class GitlabClient {
|
|
|
54
56
|
return `[icons-cli] Update icons ${this.now.toDateString()}`
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
async createActionsFromDiff(): Promise<CommitAction[]> {
|
|
59
|
+
async createActionsFromDiff(outputDir: string): Promise<CommitAction[]> {
|
|
58
60
|
const actions: CommitAction[] = []
|
|
59
61
|
|
|
60
|
-
for await (const file of getChangedFiles()) {
|
|
62
|
+
for await (const file of getChangedFiles(outputDir)) {
|
|
61
63
|
actions.push({
|
|
62
64
|
action:
|
|
63
65
|
file.status === 'untracked'
|
package/src/getChangedFiles.ts
CHANGED
|
@@ -2,12 +2,10 @@ import { promises as fs, existsSync } from 'fs'
|
|
|
2
2
|
import path from 'path'
|
|
3
3
|
import { execp } from './utils'
|
|
4
4
|
|
|
5
|
-
export const targetDir = path.resolve(process.cwd(), 'packages', 'icons')
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* dir 内で変更があったファイル情報を for await で回せるようにするやつ
|
|
9
7
|
*/
|
|
10
|
-
export async function* getChangedFiles(dir
|
|
8
|
+
export async function* getChangedFiles(dir: string) {
|
|
11
9
|
if (!existsSync(dir))
|
|
12
10
|
throw new Error(`icons-cli: target directory not found (${dir})`)
|
|
13
11
|
const gitStatus = await collectGitStatus()
|
package/src/index.ts
CHANGED
|
@@ -99,12 +99,14 @@ void yargs
|
|
|
99
99
|
async () => {
|
|
100
100
|
mustBeDefined(GITLAB_PROJECT_ID, 'GITLAB_PROJECT_ID')
|
|
101
101
|
mustBeDefined(GITLAB_ACCESS_TOKEN, 'GITLAB_ACCESS_TOKEN')
|
|
102
|
+
mustBeDefined(OUTPUT_ROOT_DIR, 'OUTPUT_ROOT_DIR')
|
|
102
103
|
|
|
103
104
|
await GitlabClient.runFromCli(
|
|
104
105
|
GITLAB_HOST ?? 'https://gitlab.com',
|
|
105
106
|
Number(GITLAB_PROJECT_ID),
|
|
106
107
|
GITLAB_ACCESS_TOKEN,
|
|
107
|
-
GITLAB_DEFAULT_BRANCH ?? 'main'
|
|
108
|
+
GITLAB_DEFAULT_BRANCH ?? 'main',
|
|
109
|
+
OUTPUT_ROOT_DIR
|
|
108
110
|
)
|
|
109
111
|
}
|
|
110
112
|
)
|
|
@@ -114,12 +116,14 @@ void yargs
|
|
|
114
116
|
{},
|
|
115
117
|
async () => {
|
|
116
118
|
mustBeDefined(GITHUB_ACCESS_TOKEN, 'GITHUB_ACCESS_TOKEN')
|
|
119
|
+
mustBeDefined(OUTPUT_ROOT_DIR, 'OUTPUT_ROOT_DIR')
|
|
117
120
|
|
|
118
121
|
await GithubClient.runFromCli(
|
|
119
122
|
GITHUB_REPO_OWNER ?? 'pixiv',
|
|
120
123
|
GITHUB_REPO_NAME ?? 'charcoal',
|
|
121
124
|
GITHUB_ACCESS_TOKEN,
|
|
122
|
-
GITHUB_DEFAULT_BRANCH ?? 'main'
|
|
125
|
+
GITHUB_DEFAULT_BRANCH ?? 'main',
|
|
126
|
+
OUTPUT_ROOT_DIR
|
|
123
127
|
)
|
|
124
128
|
}
|
|
125
129
|
)
|