tokocode 1.1.0 → 1.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0 — 2026-11-16
4
+
5
+ - Pembaruan otomatis: setiap kali dijalankan lewat `npx`, CLI memeriksa versi terbaru di npm (paling sering tiap 30 menit, maksimal 2,5 detik) dan langsung beralih ke versi itu dengan perintah yang sama. Cache npm yang basi tidak lagi membuat versi lama terpakai. Matikan dengan `--no-update` atau `TOKOCODE_NO_UPDATE=1`; terpasang global (`npm i -g`) hanya diberi petunjuk.
6
+ - `npx tokocode update`: periksa dan unduh versi terbaru sekarang.
7
+ - Tampilan baru: logo Tokocode.id (tas dengan `</>`, warna merek) di tengah layar, sambutan dan menu yang rapi; perintah lain diawali satu baris merek.
8
+
3
9
  ## 1.1.0 — 2026-11-17
4
10
 
5
11
  - `search` / `info`: katalog TokoCode dari terminal (harga, label gratis, jenis, `--json`).
@@ -7,7 +7,7 @@ import { ApiClient } from '../services/api.service.js';
7
7
  import { forgetLogin, loadLogin, saveLogin } from '../services/auth.service.js';
8
8
  import { CliError, toCliError } from '../utils/errors.js';
9
9
  import { debug } from '../utils/logger.js';
10
- import { box, details, out } from '../utils/terminal.js';
10
+ import { box, brandLine, details, out } from '../utils/terminal.js';
11
11
  import { normalizeApiUrl } from '../utils/validation.js';
12
12
  import { printTable } from './catalog.js';
13
13
  import { withSpinner } from './install.js';
@@ -32,6 +32,7 @@ function openBrowser(url) {
32
32
  * `npx tokocode login`: shows a code, opens the browser, and waits for one click on "Izinkan".
33
33
  */
34
34
  export async function runLogin(options) {
35
+ brandLine();
35
36
  const api = client(options.api);
36
37
  const start = await withSpinner('Menyiapkan login…', () => api.deviceStart({ ...ApiClient.clientInfo(), host: os.hostname().slice(0, 60) }), { silentSuccess: true });
37
38
  out.line();
@@ -124,6 +125,9 @@ export async function runWhoami(options) {
124
125
  * `npx tokocode library`: paid and free products of the signed-in customer.
125
126
  */
126
127
  export async function runLibrary(options) {
128
+ if (!options.json) {
129
+ brandLine();
130
+ }
127
131
  const api = client(options.api);
128
132
  const token = await requireLogin(api);
129
133
  const { items } = await withSpinner('Mengambil produk di akun Anda…', () => api.library(token), { silentSuccess: true }).catch((error) => forgetIfRejected(api, error));
@@ -16,7 +16,7 @@ import { removeOnInterrupt } from '../utils/cleanup.js';
16
16
  import { CliError, toCliError } from '../utils/errors.js';
17
17
  import { directoryState, fileSize, humanBytes, moveDirectory, removeQuietly } from '../utils/filesystem.js';
18
18
  import { formatDuration, ProgressBar } from '../utils/progress.js';
19
- import { box, details, out } from '../utils/terminal.js';
19
+ import { box, brandLine, details, out } from '../utils/terminal.js';
20
20
  import { compareVersions, normalizeApiUrl } from '../utils/validation.js';
21
21
  import { chooseTarget, runLibraryInstall, withSpinner } from './install.js';
22
22
  const KIND_LABEL = { komponen: 'Komponen UI', template: 'Template / source code', jasa: 'Layanan' };
@@ -25,6 +25,7 @@ const KIND_LABEL = { komponen: 'Komponen UI', template: 'Template / source code'
25
25
  * signed-in account (`npx tokocode login`), otherwise the CLI explains how to get them.
26
26
  */
27
27
  export async function runAdd(names, options) {
28
+ brandLine();
28
29
  const api = new ApiClient(normalizeApiUrl(options.api ?? process.env.TOKOCODE_API_URL ?? DEFAULT_API_URL));
29
30
  await assertAvailable(api);
30
31
  const many = names.length > 1;
@@ -5,7 +5,7 @@ import { ApiClient } from '../services/api.service.js';
5
5
  import { pendingStates, stateDir } from '../services/state.service.js';
6
6
  import { toCliError } from '../utils/errors.js';
7
7
  import { ensureWritableDirectory, freeSpace, humanBytes } from '../utils/filesystem.js';
8
- import { out, symbols } from '../utils/terminal.js';
8
+ import { brandLine, out, symbols } from '../utils/terminal.js';
9
9
  import { compareVersions, normalizeApiUrl } from '../utils/validation.js';
10
10
  /**
11
11
  * `tokocode doctor`: checks everything an installation needs and explains what to fix.
@@ -13,6 +13,7 @@ import { compareVersions, normalizeApiUrl } from '../utils/validation.js';
13
13
  * @returns true when no blocking problem was found
14
14
  */
15
15
  export async function runDoctor(apiOption) {
16
+ brandLine();
16
17
  let ok = true;
17
18
  const pass = (label, detail = '') => out.line(`${chalk.green(symbols.ok)} ${label}${detail ? chalk.dim(' · ' + detail) : ''}`);
18
19
  const fail = (label, hint) => {
@@ -21,6 +21,11 @@ ${chalk.bold('Dengan installation token:')}
21
21
  ${chalk.cyan(`${cmd} --dir D:\\Projects --name "toko saya"`)} Pilih lokasi lain (nama dengan spasi diberi tanda kutip)
22
22
  ${chalk.cyan(`${cmd} doctor`)} Periksa koneksi dan kesiapan komputer
23
23
 
24
+ ${chalk.bold('Pembaruan otomatis')}
25
+ Setiap kali dijalankan lewat npx, CLI memeriksa versi terbaru di npm (maks. tiap 30 menit)
26
+ dan langsung memakai versi itu. ${chalk.cyan(`${cmd} update`)} memeriksa sekarang juga.
27
+ Matikan dengan --no-update atau TOKOCODE_NO_UPDATE=1.
28
+
24
29
  ${chalk.bold('Installation token')}
25
30
  Buat di website TokoCode: Akun > Instalasi CLI > Buat token.
26
31
  Token sekali pakai, hanya ditampilkan sekali, dan bisa dibuat ulang bila hilang.
@@ -33,6 +38,7 @@ ${chalk.bold('Variabel lingkungan')}
33
38
  TOKOCODE_TOKEN Token (alternatif --token; tidak disimpan)
34
39
  TOKOCODE_API_URL Alamat toko bila berbeda dari bawaan
35
40
  TOKOCODE_DEBUG=1 Log diagnosis (token dan secret selalu disamarkan)
41
+ TOKOCODE_NO_UPDATE=1 Jangan memperbarui CLI otomatis
36
42
  NO_COLOR=1 Matikan warna
37
43
  `;
38
44
  }
@@ -3,7 +3,7 @@ import { DEFAULT_API_URL, PACKAGE_NAME } from '../config/constants.js';
3
3
  import { ApiClient } from '../services/api.service.js';
4
4
  import { loadLogin } from '../services/auth.service.js';
5
5
  import { pendingStates } from '../services/state.service.js';
6
- import { ask, banner, choose, isInteractive, out } from '../utils/terminal.js';
6
+ import { ask, banner, centerLine, choose, divider, isInteractive, out } from '../utils/terminal.js';
7
7
  import { normalizeApiUrl } from '../utils/validation.js';
8
8
  import { runLibrary, runLogin } from './account.js';
9
9
  import { runAdd } from './add.js';
@@ -23,9 +23,12 @@ export async function runHome(options) {
23
23
  }
24
24
  banner();
25
25
  const login = await loadLogin(api.baseUrl);
26
- out.line(chalk.bold('Selamat datang di TokoCode!') + (login ? chalk.dim(` Masuk sebagai ${login.user.name || login.user.email}`) : ''));
27
- out.line(chalk.dim('Komponen UI, template, dan source code siap pakai, langsung ke folder project Anda.'));
26
+ centerLine(chalk.bold('Selamat datang!') + chalk.dim(' Pasang komponen dan source code langsung ke folder project Anda.'));
27
+ if (login) {
28
+ centerLine(chalk.green('● ') + chalk.dim(`Masuk sebagai ${login.user.name || login.user.email}`));
29
+ }
28
30
  out.line();
31
+ divider();
29
32
  const choice = await choose('Apa yang ingin Anda lakukan?', [
30
33
  { value: 'free', label: `Pasang komponen gratis ${chalk.dim('(tanpa akun)')}` },
31
34
  { value: 'search', label: `Cari di katalog ${chalk.dim('(komponen, template, source code)')}` },
@@ -90,6 +93,7 @@ function showCommands() {
90
93
  [`${cmd} library`, 'Produk di akun Anda'],
91
94
  [`${cmd} --token TK-XXXX-…`, 'Pasang dengan installation token'],
92
95
  [`${cmd} doctor`, 'Periksa koneksi dan kesiapan komputer'],
96
+ [`${cmd} update`, 'Perbarui CLI sekarang (otomatis setiap dijalankan)'],
93
97
  [`${cmd} --help`, 'Semua opsi'],
94
98
  ];
95
99
  const width = Math.max(...rows.map(([command]) => command.length));
@@ -16,7 +16,7 @@ import { CancelledError, CliError, toCliError } from '../utils/errors.js';
16
16
  import { directoryState, ensureWritableDirectory, freeSpace, humanBytes, moveDirectory, removeQuietly, resolveUserPath } from '../utils/filesystem.js';
17
17
  import { debug } from '../utils/logger.js';
18
18
  import { formatDuration, ProgressBar } from '../utils/progress.js';
19
- import { ask, banner, box, choose, confirm, details, isInteractive, out, step } from '../utils/terminal.js';
19
+ import { ask, banner, box, centerLine, choose, confirm, details, divider, isInteractive, out, step } from '../utils/terminal.js';
20
20
  import { compareVersions, folderNameProblem, normalizeApiUrl, suggestFolderName } from '../utils/validation.js';
21
21
  const STEPS = 5;
22
22
  /**
@@ -27,8 +27,9 @@ export async function runInstall(options, view = {}) {
27
27
  const api = new ApiClient(normalizeApiUrl(options.api ?? process.env.TOKOCODE_API_URL ?? DEFAULT_API_URL));
28
28
  if (view.banner !== false) {
29
29
  banner();
30
- out.line(chalk.bold('Selamat datang di TokoCode!'));
30
+ centerLine(chalk.bold('Selamat datang!') + chalk.dim(' Pasang produk yang sudah Anda beli dengan installation token.'));
31
31
  out.line();
32
+ divider();
32
33
  }
33
34
  warnOldNode();
34
35
  await withSpinner('Menghubungi server TokoCode…', async () => {
@@ -0,0 +1,42 @@
1
+ import { spawn } from 'node:child_process';
2
+ import chalk from 'chalk';
3
+ import { CLI_VERSION, EXIT, PACKAGE_NAME } from '../config/constants.js';
4
+ import { latestVersion, planUpdate } from '../services/update.service.js';
5
+ import { CliError } from '../utils/errors.js';
6
+ import { brandLine, details, out } from '../utils/terminal.js';
7
+ import { compareVersions } from '../utils/validation.js';
8
+ import { withSpinner } from './install.js';
9
+ /**
10
+ * `npx tokocode update`: checks npm now (ignoring the 30-minute cache) and fetches the newest CLI, so the next
11
+ * `npx tokocode` starts with it. Normally not needed: every run updates itself automatically.
12
+ */
13
+ export async function runUpdate() {
14
+ brandLine();
15
+ const latest = await withSpinner('Memeriksa versi terbaru di npm…', () => latestVersion(true), { silentSuccess: true });
16
+ if (!latest) {
17
+ throw new CliError('network_error', 'Versi terbaru tidak dapat diperiksa.', 'Periksa koneksi internet, lalu coba lagi.');
18
+ }
19
+ out.line();
20
+ details([['Versi Anda', CLI_VERSION], ['Versi terbaru', latest]]);
21
+ out.line();
22
+ if (compareVersions(latest, CLI_VERSION) <= 0) {
23
+ out.ok('TokoCode CLI sudah versi terbaru.');
24
+ return EXIT.ok;
25
+ }
26
+ const plan = planUpdate(latest, ['--version'], { ...process.env, TOKOCODE_NO_UPDATE: '' });
27
+ if (plan.action !== 'relaunch') {
28
+ out.info(`Perbarui dengan: ${chalk.cyan(`npm install -g ${PACKAGE_NAME}@latest`)}`);
29
+ return EXIT.ok;
30
+ }
31
+ out.line(chalk.cyan(`↻ Mengunduh TokoCode CLI ${latest}…`));
32
+ const code = await new Promise((resolve) => {
33
+ const child = spawn(plan.command, plan.args, { stdio: ['ignore', 'ignore', 'inherit'], env: { ...process.env, TOKOCODE_NO_UPDATE: '1' } });
34
+ child.on('error', () => resolve(1));
35
+ child.on('exit', (exitCode) => resolve(exitCode ?? 1));
36
+ });
37
+ if (code !== 0) {
38
+ throw new CliError('update_failed', `TokoCode CLI ${latest} belum dapat diunduh.`, `Coba lagi beberapa menit lagi, atau jalankan: npx --prefer-online ${PACKAGE_NAME}@latest`);
39
+ }
40
+ out.ok(`TokoCode CLI ${latest} siap. Perintah npx ${PACKAGE_NAME} berikutnya memakai versi ini.`);
41
+ return EXIT.ok;
42
+ }
package/dist/index.js CHANGED
@@ -8,7 +8,9 @@ import { helpFooter } from './commands/help.js';
8
8
  import { runDoctor } from './commands/doctor.js';
9
9
  import { runHome } from './commands/home.js';
10
10
  import { runInstall } from './commands/install.js';
11
+ import { runUpdate } from './commands/update.js';
11
12
  import { runVersion } from './commands/version.js';
13
+ import { autoUpdate } from './services/update.service.js';
12
14
  import { runLibrary, runLogin, runLogout, runWhoami } from './commands/account.js';
13
15
  import { runAdd } from './commands/add.js';
14
16
  import { runInfo, runSearch } from './commands/catalog.js';
@@ -18,7 +20,12 @@ import { destroyAgents } from './utils/http.js';
18
20
  import { debug, setDebug } from './utils/logger.js';
19
21
  import { closePrompts, out, printError } from './utils/terminal.js';
20
22
  let interrupted = false;
23
+ // True while a newer CLI runs in our place (automatic update): it handles Ctrl+C itself.
24
+ let delegated = false;
21
25
  process.on('SIGINT', () => {
26
+ if (delegated) {
27
+ return;
28
+ }
22
29
  if (interrupted) {
23
30
  process.exit(EXIT.cancelled);
24
31
  }
@@ -30,6 +37,14 @@ process.on('SIGINT', () => {
30
37
  process.exit(EXIT.cancelled);
31
38
  });
32
39
  async function main(argv) {
40
+ // Automatic update: an older CLI started with npx hands over to the newest one (same arguments).
41
+ const handedOver = await autoUpdate(argv.slice(2), () => {
42
+ delegated = true;
43
+ });
44
+ if (handedOver !== null) {
45
+ return handedOver;
46
+ }
47
+ argv = argv.filter((arg, index) => index < 2 || arg !== '--no-update');
33
48
  const program = new Command();
34
49
  program
35
50
  .name(PACKAGE_NAME)
@@ -70,6 +85,13 @@ async function main(argv) {
70
85
  exitCode = (await runDoctor(options.api)) ? EXIT.ok : EXIT.error;
71
86
  });
72
87
  program.command('version').description('Tampilkan versi CLI, Node.js, dan sistem').action(() => runVersion());
88
+ program
89
+ .command('update')
90
+ .alias('upgrade')
91
+ .description('Periksa dan unduh TokoCode CLI terbaru sekarang (biasanya otomatis)')
92
+ .action(async () => {
93
+ exitCode = await runUpdate();
94
+ });
73
95
  // Catalogue, free products and the customer's account (CLI 1.1).
74
96
  const apiOption = () => new Option('--api <url>', 'Alamat toko').env('TOKOCODE_API_URL');
75
97
  program
@@ -0,0 +1,118 @@
1
+ import { spawn } from 'node:child_process';
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import chalk from 'chalk';
5
+ import { CLI_VERSION, PACKAGE_NAME } from '../config/constants.js';
6
+ import { debug } from '../utils/logger.js';
7
+ import { compareVersions } from '../utils/validation.js';
8
+ import { configDir } from './auth.service.js';
9
+ /**
10
+ * Automatic updates. Before a command runs, the CLI asks npm for the newest version (cached for
11
+ * CHECK_EVERY_MS, at most CHECK_TIMEOUT_MS on a slow network). Started through `npx`, an older CLI hands over
12
+ * to the newest one through npm itself (`npm exec --prefer-online`, so a stale npm cache cannot pick the
13
+ * old version again) with the same arguments; installed globally, it only shows how to update.
14
+ * Off with TOKOCODE_NO_UPDATE=1, --no-update, or in CI.
15
+ */
16
+ export const CHECK_EVERY_MS = 30 * 60 * 1000;
17
+ const CHECK_TIMEOUT_MS = 2500;
18
+ const REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
19
+ const VERSION = /^\d+\.\d+\.\d+$/;
20
+ function cacheFile() {
21
+ return path.join(configDir(), 'update-check.json');
22
+ }
23
+ async function readCache() {
24
+ try {
25
+ const data = JSON.parse(await fs.readFile(cacheFile(), 'utf8'));
26
+ return typeof data.checked_at === 'number' && typeof data.latest === 'string' && VERSION.test(data.latest) ? data : null;
27
+ }
28
+ catch {
29
+ return null;
30
+ }
31
+ }
32
+ async function writeCache(latest) {
33
+ try {
34
+ await fs.mkdir(configDir(), { recursive: true, mode: 0o700 });
35
+ await fs.writeFile(cacheFile(), JSON.stringify({ checked_at: Date.now(), latest }) + '\n', { mode: 0o600 });
36
+ }
37
+ catch (error) {
38
+ debug('update cache not written', error.message);
39
+ }
40
+ }
41
+ /** Newest version on npm, or null when npm cannot be reached (the CLI then simply carries on). */
42
+ export async function latestVersion(force = false, fetcher = fetch) {
43
+ const cached = await readCache();
44
+ if (!force && cached && Date.now() - cached.checked_at < CHECK_EVERY_MS) {
45
+ return cached.latest;
46
+ }
47
+ try {
48
+ const response = await fetcher(REGISTRY_URL, { headers: { Accept: 'application/json' }, signal: AbortSignal.timeout(CHECK_TIMEOUT_MS) });
49
+ if (!response.ok) {
50
+ throw new Error(`HTTP ${response.status}`);
51
+ }
52
+ const latest = String((await response.json()).version ?? '');
53
+ if (!VERSION.test(latest)) {
54
+ throw new Error(`unexpected version "${latest}"`);
55
+ }
56
+ await writeCache(latest);
57
+ return latest;
58
+ }
59
+ catch (error) {
60
+ debug('update check skipped', error.message);
61
+ return cached?.latest ?? null;
62
+ }
63
+ }
64
+ /**
65
+ * What to do with the newest version: nothing, show a hint (global install), or relaunch through npm (npx).
66
+ */
67
+ export function planUpdate(latest, args, env = process.env, current = CLI_VERSION) {
68
+ if (!latest || compareVersions(latest, current) <= 0 || updatesDisabled(args, env)) {
69
+ return { action: 'none' };
70
+ }
71
+ const npmCli = env.npm_execpath ?? '';
72
+ if (env.npm_command !== 'exec' || !/npm-cli\.js$/i.test(npmCli)) {
73
+ return { action: 'notify', latest };
74
+ }
75
+ return {
76
+ action: 'relaunch',
77
+ latest,
78
+ command: process.execPath,
79
+ args: [npmCli, 'exec', '--yes', '--prefer-online', `--package=${PACKAGE_NAME}@${latest}`, '--', PACKAGE_NAME, ...args],
80
+ };
81
+ }
82
+ export function updatesDisabled(args, env = process.env) {
83
+ return ['1', 'true', 'yes'].includes(String(env.TOKOCODE_NO_UPDATE ?? '').toLowerCase())
84
+ || env.CI === 'true'
85
+ || args.includes('--no-update')
86
+ || args[0] === 'update';
87
+ }
88
+ /**
89
+ * Runs the update check before a command. Returns the exit code of the newer CLI when it took over, or null
90
+ * to carry on with this one. Messages go to stderr so `--json` output stays clean.
91
+ */
92
+ export async function autoUpdate(args, onDelegate) {
93
+ if (updatesDisabled(args)) {
94
+ return null;
95
+ }
96
+ const plan = planUpdate(await latestVersion(), args);
97
+ if (plan.action === 'notify') {
98
+ process.stderr.write(chalk.yellow(`\n! TokoCode CLI ${plan.latest} tersedia (Anda memakai ${CLI_VERSION}). Perbarui: npm install -g ${PACKAGE_NAME}@latest\n`));
99
+ return null;
100
+ }
101
+ if (plan.action !== 'relaunch') {
102
+ return null;
103
+ }
104
+ process.stderr.write(chalk.cyan(`\n↻ Memperbarui TokoCode CLI ${CLI_VERSION} → ${plan.latest}…\n`));
105
+ onDelegate();
106
+ return await new Promise((resolve) => {
107
+ const child = spawn(plan.command, plan.args, {
108
+ stdio: 'inherit',
109
+ env: { ...process.env, TOKOCODE_NO_UPDATE: '1', TOKOCODE_UPDATED_FROM: CLI_VERSION },
110
+ });
111
+ child.on('error', (error) => {
112
+ debug('relaunch failed', error.message);
113
+ process.stderr.write(chalk.yellow('! Pembaruan otomatis gagal; melanjutkan dengan versi ini.\n'));
114
+ resolve(null);
115
+ });
116
+ child.on('exit', (code, signal) => resolve(signal ? 130 : code ?? 1));
117
+ });
118
+ }
@@ -1,7 +1,7 @@
1
1
  import { createInterface } from 'node:readline/promises';
2
2
  import chalk from 'chalk';
3
3
  import { CancelledError, CliError } from './errors.js';
4
- import { EXIT } from '../config/constants.js';
4
+ import { CLI_VERSION, EXIT } from '../config/constants.js';
5
5
  /**
6
6
  * Terminal output and prompts. Plain ASCII fallbacks are used where the console cannot show
7
7
  * box-drawing characters; colours follow chalk's detection (NO_COLOR / FORCE_COLOR respected).
@@ -47,9 +47,59 @@ export function box(lines, color = chalk.cyan) {
47
47
  const rows = [color(tl + h.repeat(width) + tr), pad(''), ...lines.map(pad), pad(''), color(bl + h.repeat(width) + br)];
48
48
  return rows.join('\n');
49
49
  }
50
- export function banner() {
50
+ /** Brand colours of the website logo (docs/Design): the bag, and a lighter blue that reads on dark terminals. */
51
+ const BRAND = '#2F4DFF';
52
+ const BRAND_TEXT = '#7C92FF';
53
+ let brandShown = false;
54
+ function centred(text, width) {
55
+ return ' '.repeat(Math.max(0, Math.floor((width - visibleLength(text)) / 2))) + text;
56
+ }
57
+ function wordmark() {
58
+ return chalk.bold('Tokocode') + chalk.bold.hex(BRAND_TEXT)('.id');
59
+ }
60
+ /**
61
+ * The Tokocode.id logo as on the website (shopping bag with </>, then the wordmark), centred in the terminal.
62
+ * Drawn with block characters that every Windows console font has; without colours the bag is solid blocks.
63
+ */
64
+ export function banner(tagline = 'Komponen UI · Template · Source code') {
65
+ brandShown = true;
66
+ const width = Math.min(process.stdout.columns || 80, 120);
67
+ const blue = chalk.hex(BRAND);
68
+ const body = (inner) => (chalk.level > 0 ? chalk.bgHex(BRAND).hex('#FFFFFF').bold(inner) : inner.replace(/ /g, '█'));
69
+ const mark = [
70
+ blue(' ▄▀▀▀▀▀▄ '),
71
+ blue(' ▄▄▄▄█▄▄▄▄▄█▄▄▄▄ '),
72
+ body(' '),
73
+ body(' </> '),
74
+ body(' '),
75
+ blue(' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ '),
76
+ ];
77
+ out.line();
78
+ mark.forEach((row) => out.line(centred(row, width)));
79
+ out.line();
80
+ out.line(centred(wordmark(), width));
81
+ out.line(centred(chalk.dim(`${tagline} · CLI ${CLI_VERSION}`), width));
82
+ out.line();
83
+ }
84
+ /** A line centred under the logo (welcome text, signed-in account). */
85
+ export function centerLine(text) {
86
+ out.line(centred(text, Math.min(process.stdout.columns || 80, 120)));
87
+ }
88
+ /** Thin divider between the logo block and what follows. */
89
+ export function divider() {
90
+ const width = Math.min(process.stdout.columns || 80, 120);
91
+ out.line(centred(chalk.dim((unicode ? '─' : '-').repeat(Math.min(56, width - 4))), width));
92
+ out.line();
93
+ }
94
+ /** One-line brand header for commands that do not open with the full logo (shown once per run). */
95
+ export function brandLine() {
96
+ if (brandShown || !process.stdout.isTTY) {
97
+ return;
98
+ }
99
+ brandShown = true;
100
+ const tag = chalk.level > 0 ? chalk.bgHex(BRAND).hex('#FFFFFF').bold(' </> ') : '[</>]';
51
101
  out.line();
52
- out.line(box([chalk.bold.white('TOKOCODE CLI'), chalk.cyan('SOURCE CODE INSTALLER')]));
102
+ out.line(`${tag} ${wordmark()} ${chalk.dim(`CLI ${CLI_VERSION}`)}`);
53
103
  out.line();
54
104
  }
55
105
  /** Two-column details ("Produk : …"). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokocode",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Pasang source code yang sudah Anda beli di TokoCode langsung dari terminal: npx tokocode",
5
5
  "keywords": [
6
6
  "tokocode",