hlmnhkl-ui 0.35.0 → 0.35.1

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.
Files changed (2) hide show
  1. package/package.json +3 -2
  2. package/scripts/add.js +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hlmnhkl-ui",
3
- "version": "0.35.0",
3
+ "version": "0.35.1",
4
4
  "description": "React components in black, white and grey with one blue accent. Copy them into your app with npx hlmnhkl-ui add <name>.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://ui.hlmnhkl.my",
@@ -25,7 +25,8 @@
25
25
  ],
26
26
  "scripts": {
27
27
  "typecheck": "tsc -p tsconfig.json",
28
- "add": "node scripts/add.js"
28
+ "add": "node scripts/add.js",
29
+ "prepublishOnly": "node scripts/check-publish.mjs"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/react": "^19.3.0",
package/scripts/add.js CHANGED
@@ -41,6 +41,17 @@ const KINDS = [
41
41
  { key: 'theme', plural: 'Themes', folder: 'themes', pro: true, single: true },
42
42
  ].map((k) => ({ ...k, dir: join(SRC, k.folder) }))
43
43
 
44
+ // The import lines as they read from the app's entry file. A folder inside src/ is written
45
+ // relative to src/ (Vite, Next and most setups keep the entry there), so it can be pasted as is.
46
+ function fromEntry(folder, both = true) {
47
+ const clean = folder.replace(/^\.\//, '').replace(/\/$/, '')
48
+ const inSrc = clean.startsWith('src/')
49
+ const rel = inSrc ? clean.slice(4) : clean
50
+ const where = inSrc ? 'in your entry file inside src/ (for example src/main.tsx):' : 'in a file at your project root:'
51
+ const lines = [`import './${rel}/tokens.css'`, ...(both ? [`import './${rel}/base.css'`] : [])]
52
+ return `${where}\n${lines.map((l) => ` ${l}`).join('\n')}`
53
+ }
54
+
44
55
  function fail(message, usage = true) {
45
56
  console.error(`Error: ${message}`)
46
57
  if (usage) console.error(`\n${USAGE}`)
@@ -352,7 +363,7 @@ function runInit(opts) {
352
363
  if (!opts.dryRun) writeFileSync(config, `${JSON.stringify({ to: folder }, null, 2)}\n`)
353
364
  console.log(` ${CONFIG}: added, so later commands put files in ${folder}`)
354
365
  }
355
- console.log(`\nNext:\n 1. Import both once at your app root, tokens first:\n import './${folder.replace(/^\.\//, '')}/tokens.css'\n import './${folder.replace(/^\.\//, '')}/base.css'`)
366
+ console.log(`\nNext:\n 1. Import both once, tokens first, ${fromEntry(folder)}`)
356
367
  console.log(` 2. Add your first component: npx hlmnhkl-ui add button`)
357
368
  console.log(` See everything there is: npx hlmnhkl-ui list, or ${SITE}`)
358
369
  }
@@ -417,7 +428,7 @@ function runAdd(opts) {
417
428
  for (const s of skipped) console.log(` ${s}`)
418
429
  if (skipped.some((s) => /^(tokens|base)\.css /.test(s))) console.log(' tokens.css and base.css are never replaced, so your theme edits stay.')
419
430
  }
420
- if (tokensNew) console.log(`Next: import ${join(opts.to || readConfig()?.to || DEFAULT_TO, 'tokens.css')} once at your app root (or run init).`)
431
+ if (tokensNew) console.log(`Next: import tokens.css once ${fromEntry(opts.to || readConfig()?.to || DEFAULT_TO, false)} (or run init).`)
421
432
  if (items.some((i) => i.kind === 'theme')) console.log('Themes: import each one after tokens.css, then set data-theme-brand or data-density on <html>.')
422
433
  }
423
434