@proappstore/cli 2.6.6 → 2.6.7
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../../src/lib/config.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { mkdtemp, writeFile, rm, readFile } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
// We need to mock homedir() to point to a temp dir so tests don't
|
|
6
|
+
// touch the real ~/.proappstore/config.json.
|
|
7
|
+
const testHome = await mkdtemp(join(tmpdir(), 'pas-cli-test-'));
|
|
8
|
+
vi.mock('node:os', async () => {
|
|
9
|
+
const actual = await vi.importActual('node:os');
|
|
10
|
+
return { ...actual, homedir: () => testHome };
|
|
11
|
+
});
|
|
12
|
+
const { readConfig, writeConfig, resolveToken } = await import('./config.js');
|
|
13
|
+
afterEach(async () => {
|
|
14
|
+
// Clean up config between tests
|
|
15
|
+
try {
|
|
16
|
+
await rm(join(testHome, '.proappstore'), { recursive: true, force: true });
|
|
17
|
+
}
|
|
18
|
+
catch { }
|
|
19
|
+
});
|
|
20
|
+
describe('readConfig', () => {
|
|
21
|
+
it('returns defaults when no config file exists', async () => {
|
|
22
|
+
const config = await readConfig();
|
|
23
|
+
expect(config.apiBase).toBe('https://api.proappstore.online');
|
|
24
|
+
expect(config.authApiBase).toBe('https://api.freeappstore.online');
|
|
25
|
+
expect(config.session).toBeUndefined();
|
|
26
|
+
});
|
|
27
|
+
it('merges saved config over defaults', async () => {
|
|
28
|
+
await writeConfig({
|
|
29
|
+
apiBase: 'https://custom-api.example.com/',
|
|
30
|
+
authApiBase: 'https://custom-auth.example.com/',
|
|
31
|
+
session: { token: 'tok-123', obtainedAt: 1000 },
|
|
32
|
+
});
|
|
33
|
+
const config = await readConfig();
|
|
34
|
+
// Trailing slash is stripped
|
|
35
|
+
expect(config.apiBase).toBe('https://custom-api.example.com');
|
|
36
|
+
expect(config.session?.token).toBe('tok-123');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('writeConfig', () => {
|
|
40
|
+
it('creates config dir with restricted permissions', async () => {
|
|
41
|
+
await writeConfig({
|
|
42
|
+
apiBase: 'https://api.proappstore.online',
|
|
43
|
+
authApiBase: 'https://api.freeappstore.online',
|
|
44
|
+
});
|
|
45
|
+
const raw = await readFile(join(testHome, '.proappstore', 'config.json'), 'utf8');
|
|
46
|
+
const parsed = JSON.parse(raw);
|
|
47
|
+
expect(parsed.apiBase).toBe('https://api.proappstore.online');
|
|
48
|
+
});
|
|
49
|
+
it('round-trips session data', async () => {
|
|
50
|
+
const config = {
|
|
51
|
+
apiBase: 'https://api.proappstore.online',
|
|
52
|
+
authApiBase: 'https://api.freeappstore.online',
|
|
53
|
+
session: { token: 'test-token', obtainedAt: Date.now() },
|
|
54
|
+
};
|
|
55
|
+
await writeConfig(config);
|
|
56
|
+
const loaded = await readConfig();
|
|
57
|
+
expect(loaded.session?.token).toBe('test-token');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('resolveToken', () => {
|
|
61
|
+
const origEnv = process.env.PAS_SESSION_TOKEN;
|
|
62
|
+
afterEach(() => {
|
|
63
|
+
if (origEnv === undefined)
|
|
64
|
+
delete process.env.PAS_SESSION_TOKEN;
|
|
65
|
+
else
|
|
66
|
+
process.env.PAS_SESSION_TOKEN = origEnv;
|
|
67
|
+
});
|
|
68
|
+
it('returns CLI flag token first', () => {
|
|
69
|
+
process.env.PAS_SESSION_TOKEN = 'env-tok';
|
|
70
|
+
expect(resolveToken('cli-tok')).toBe('cli-tok');
|
|
71
|
+
});
|
|
72
|
+
it('falls back to env var', () => {
|
|
73
|
+
process.env.PAS_SESSION_TOKEN = 'env-tok';
|
|
74
|
+
expect(resolveToken()).toBe('env-tok');
|
|
75
|
+
});
|
|
76
|
+
it('falls back to config file', async () => {
|
|
77
|
+
delete process.env.PAS_SESSION_TOKEN;
|
|
78
|
+
await writeConfig({
|
|
79
|
+
apiBase: 'https://api.proappstore.online',
|
|
80
|
+
authApiBase: 'https://api.freeappstore.online',
|
|
81
|
+
session: { token: 'file-tok', obtainedAt: 1000 },
|
|
82
|
+
});
|
|
83
|
+
expect(resolveToken()).toBe('file-tok');
|
|
84
|
+
});
|
|
85
|
+
it('returns null when nothing is available', () => {
|
|
86
|
+
delete process.env.PAS_SESSION_TOKEN;
|
|
87
|
+
expect(resolveToken()).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=config.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.test.js","sourceRoot":"","sources":["../../src/lib/config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,kEAAkE;AAClE,6CAA6C;AAC7C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;AAChE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IAC5B,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,YAAY,CAA2B,SAAS,CAAC,CAAC;IAC1E,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AA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AAG,CAAC,iBAAiB,GAAG,OAAO,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,SAAS,CAAC;QAC1C,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,SAAS,CAAC;QAC1C,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QACzC,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QACrC,MAAM,WAAW,CAAC;YAChB,OAAO,EAAE,gCAAgC;YACzC,WAAW,EAAE,iCAAiC;YAC9C,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE;SACjD,CAAC,CAAC;QACH,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QACrC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proappstore/cli",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"description": "pas — CLI for publishing paid apps to proappstore.online",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"commander": "^12.1.0",
|
|
25
|
-
"@proappstore/compliance": "0.2.
|
|
25
|
+
"@proappstore/compliance": "0.2.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^22.0.0",
|