dunsocial 0.7.0 → 0.8.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/README.md +1 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/scripts/postinstall.js +28 -5
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -95,7 +95,7 @@ Env:
|
|
|
95
95
|
Exit codes:
|
|
96
96
|
0 ok | 1 usage | 2 auth | 3 forbidden | 4 validation | 5 not found | 6 rate limit | 7 network
|
|
97
97
|
|
|
98
|
-
Docs: https://dunsocial.com
|
|
98
|
+
Docs: https://dunsocial.com/docs/cli
|
|
99
99
|
`;function o(U){return{auth:`dun auth
|
|
100
100
|
|
|
101
101
|
login [--token] Device-code browser login (default) or --token for CI
|
|
@@ -212,7 +212,7 @@ Env:
|
|
|
212
212
|
Exit codes:
|
|
213
213
|
0 ok | 1 usage | 2 auth | 3 forbidden | 4 validation | 5 not found | 6 rate limit | 7 network
|
|
214
214
|
|
|
215
|
-
Docs: https://dunsocial.com
|
|
215
|
+
Docs: https://dunsocial.com/docs/cli
|
|
216
216
|
`}import{mkdir as gU,readFile as c0,writeFile as rU,chmod as lU,unlink as sU}from"node:fs/promises";import{dirname as tU,join as XU}from"node:path";import{homedir as aU}from"node:os";var M="0.4.0";function e(){if(process.env.DUN_CONFIG)return process.env.DUN_CONFIG;let U=process.env.XDG_CONFIG_HOME,D=U?U:XU(aU(),".config");return XU(D,"dunsocial","config.json")}function j(){return e()}async function b(U){let D=e();await gU(tU(D),{recursive:!0});let O={...U,updatedAt:new Date().toISOString()};await rU(D,`${JSON.stringify(O,null,2)}
|
|
217
217
|
`,"utf8");try{await lU(D,384)}catch{}}async function ZU(){let U=e();try{await sU(U)}catch(D){if(D.code!=="ENOENT")throw new Q(`Failed to clear config: ${D.message}`,z.USAGE)}}function N(U){if(!U.token)throw new Q("Not authenticated. Run `dun auth login` (or `dun auth login --token <token>` / set DUN_TOKEN).",z.AUTH);return U.token}function P(U){if(!U.workspaceId)throw new Q("No workspace selected. Run `dun workspace use <id|slug>` or pass --workspace / DUN_WORKSPACE_ID.",z.VALIDATION);return U.workspaceId}var JU=["█▀▀▄ █ █ █▀▀▄ █▀▀▀ █▀▀█ █▀▀▀ ▀█▀ █▀▀█ █","█ █ █ █ █ █ ▀▀▀█ █ █ █ █ █▀▀█ █","▀▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀"].join(`
|
|
218
218
|
`),RU=["█▀▀▄ █ █ █▀▀▄","█ █ █ █ █ █","▀▀▀▀ ▀▀▀▀ ▀ ▀",""," DunSocial"].join(`
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { pathToFileURL } from 'node:url';
|
|
10
|
+
|
|
8
11
|
const BANNER_FULL = [
|
|
9
12
|
'█▀▀▄ █ █ █▀▀▄ █▀▀▀ █▀▀█ █▀▀▀ ▀█▀ █▀▀█ █',
|
|
10
13
|
'█ █ █ █ █ █ ▀▀▀█ █ █ █ █ █▀▀█ █',
|
|
@@ -19,6 +22,9 @@ const BANNER_MINI = [
|
|
|
19
22
|
' DunSocial'
|
|
20
23
|
].join('\n');
|
|
21
24
|
|
|
25
|
+
/** Keep in sync with apps/cli/src/commands/help.ts Docs line. */
|
|
26
|
+
export const DOCS_URL = 'https://dunsocial.com/docs/cli';
|
|
27
|
+
|
|
22
28
|
function isCi() {
|
|
23
29
|
const env = process.env;
|
|
24
30
|
return (
|
|
@@ -36,13 +42,29 @@ function maxWidth(art) {
|
|
|
36
42
|
return Math.max(...art.split('\n').map((line) => line.length));
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
function renderBanner(columns) {
|
|
45
|
+
export function renderBanner(columns) {
|
|
40
46
|
const cols = columns > 0 ? columns : 80;
|
|
41
47
|
if (cols >= maxWidth(BANNER_FULL)) return BANNER_FULL;
|
|
42
48
|
if (cols >= maxWidth(BANNER_MINI)) return BANNER_MINI;
|
|
43
49
|
return 'DunSocial';
|
|
44
50
|
}
|
|
45
51
|
|
|
52
|
+
/** Human tip lines after a global install (exported for tests). */
|
|
53
|
+
export function gettingStartedTip() {
|
|
54
|
+
return [
|
|
55
|
+
'Get started:',
|
|
56
|
+
' dun auth login',
|
|
57
|
+
' dun workspace list',
|
|
58
|
+
' dun workspace use <slug>',
|
|
59
|
+
' dun accounts list',
|
|
60
|
+
' dun posts publish --text "Hello from DunSocial" --accounts ACCOUNT_ID',
|
|
61
|
+
'',
|
|
62
|
+
' dun --help',
|
|
63
|
+
` Docs: ${DOCS_URL}`,
|
|
64
|
+
''
|
|
65
|
+
].join('\n');
|
|
66
|
+
}
|
|
67
|
+
|
|
46
68
|
function main() {
|
|
47
69
|
if (!process.stderr.isTTY || isCi()) return;
|
|
48
70
|
|
|
@@ -55,13 +77,14 @@ function main() {
|
|
|
55
77
|
const banner = renderBanner(columns);
|
|
56
78
|
|
|
57
79
|
process.stderr.write(`\n${banner}\n\n`);
|
|
58
|
-
process.stderr.write(
|
|
59
|
-
process.stderr.write(' dun --help\n');
|
|
60
|
-
process.stderr.write(' Docs: https://dunsocial.com\n\n');
|
|
80
|
+
process.stderr.write(`${gettingStartedTip()}\n`);
|
|
61
81
|
}
|
|
62
82
|
|
|
63
83
|
try {
|
|
64
|
-
|
|
84
|
+
const entry = process.argv[1] ? pathToFileURL(path.resolve(process.argv[1])).href : '';
|
|
85
|
+
if (entry && import.meta.url === entry) {
|
|
86
|
+
main();
|
|
87
|
+
}
|
|
65
88
|
} catch {
|
|
66
89
|
// never fail install
|
|
67
90
|
}
|