Skip to content

Commit fbdacff

Browse files
committed
add gitignore check
1 parent b725d2b commit fbdacff

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

cli.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@
136136
"hasValue": true
137137
},
138138
"intermediaDir": {
139-
"default": ".pushy/intermedia/${platform}",
139+
"default": "${tempDir}/intermedia/${platform}",
140140
"hasValue": true
141141
},
142142
"output": {
143-
"default": ".pushy/output/${platform}.${time}.ppk",
143+
"default": "${tempDir}/output/${platform}.${time}.ppk",
144144
"hasValue": true
145145
},
146146
"sourcemap": {
@@ -167,7 +167,7 @@
167167
"description": "Create diff patch",
168168
"options": {
169169
"output": {
170-
"default": ".pushy/output/diff",
170+
"default": "${tempDir}/output/diff",
171171
"hasValue": true
172172
}
173173
}
@@ -176,7 +176,7 @@
176176
"description": "Create diff patch from a Android package(.apk)",
177177
"options": {
178178
"output": {
179-
"default": ".pushy/output/diff-${time}.apk-patch",
179+
"default": "${tempDir}/output/diff-${time}.apk-patch",
180180
"hasValue": true
181181
}
182182
}
@@ -185,7 +185,7 @@
185185
"description": "Create diff patch from a iOS package(.ipa)",
186186
"options": {
187187
"output": {
188-
"default": ".pushy/output/diff-${time}.ipa-patch",
188+
"default": "${tempDir}/output/diff-${time}.ipa-patch",
189189
"hasValue": true
190190
}
191191
}
@@ -194,7 +194,7 @@
194194
"description": "Create hdiff patch",
195195
"options": {
196196
"output": {
197-
"default": ".pushy/output/hdiff",
197+
"default": "${tempDir}/output/hdiff",
198198
"hasValue": true
199199
}
200200
}
@@ -203,7 +203,7 @@
203203
"description": "Create hdiff patch from a Android package(.apk)",
204204
"options": {
205205
"output": {
206-
"default": ".pushy/output/hdiff-${time}.apk-patch",
206+
"default": "${tempDir}/output/hdiff-${time}.apk-patch",
207207
"hasValue": true
208208
}
209209
}
@@ -212,7 +212,7 @@
212212
"description": "Create hdiff patch from a Prepare package(.ppk)",
213213
"options": {
214214
"output": {
215-
"default": ".pushy/output/hdiff-${time}.ppk-patch",
215+
"default": "${tempDir}/output/hdiff-${time}.ppk-patch",
216216
"hasValue": true
217217
}
218218
}
@@ -221,7 +221,7 @@
221221
"description": "Create hdiff patch from a Harmony package(.app)",
222222
"options": {
223223
"output": {
224-
"default": ".pushy/output/hdiff-${time}.app-patch",
224+
"default": "${tempDir}/output/hdiff-${time}.app-patch",
225225
"hasValue": true
226226
}
227227
}
@@ -230,7 +230,7 @@
230230
"description": "Create hdiff patch from a iOS package(.ipa)",
231231
"options": {
232232
"output": {
233-
"default": ".pushy/output/hdiff-${time}.ipa-patch",
233+
"default": "${tempDir}/output/hdiff-${time}.ipa-patch",
234234
"hasValue": true
235235
}
236236
}
@@ -241,4 +241,4 @@
241241
"default": false
242242
}
243243
}
244-
}
244+
}

src/bundle.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import os from 'node:os';
1212
const properties = require('properties');
1313
import { depVersions } from './utils/dep-versions';
1414
import { t } from './utils/i18n';
15+
import { tempDir } from './utils/constants';
1516

1617
let bsdiff;
1718
let hdiff;
@@ -908,6 +909,7 @@ export const commands = {
908909
disableHermes,
909910
} = translateOptions({
910911
...options,
912+
tempDir,
911913
platform,
912914
});
913915

src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import updateNotifier from 'update-notifier';
55
import { printVersionCommand } from './utils';
66
import pkg from '../package.json';
77
import { t } from './utils/i18n';
8+
import { addGitIgnore } from './utils/add-gitignore';
89

910
updateNotifier({ pkg }).notify({
1011
isGlobal: true,
@@ -32,6 +33,7 @@ const commands = {
3233
};
3334

3435
async function run() {
36+
addGitIgnore();
3537
await printVersionCommand();
3638
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
3739
process.exit();

src/utils/add-gitignore.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { credentialFile, tempDir } from './constants';
4+
5+
export function addGitIgnore() {
6+
const shouldIgnore = [credentialFile, tempDir];
7+
8+
const gitignorePath = path.join(process.cwd(), '.gitignore');
9+
10+
if (!fs.existsSync(gitignorePath)) {
11+
return;
12+
}
13+
14+
const gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8');
15+
16+
const gitignoreLines = gitignoreContent.split('\n');
17+
18+
for (const line of gitignoreLines) {
19+
const index = shouldIgnore.indexOf(line);
20+
if (index !== -1) {
21+
shouldIgnore.splice(index, 1);
22+
}
23+
}
24+
25+
if (shouldIgnore.length > 0) {
26+
for (const line of shouldIgnore) {
27+
gitignoreLines.push(line);
28+
console.log(`Added ${line} to .gitignore`);
29+
}
30+
31+
fs.writeFileSync(gitignorePath, gitignoreLines.join('\n'));
32+
}
33+
}

0 commit comments

Comments
 (0)