@favish/staffbase-utils 0.1.0 → 0.1.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/README.md +62 -4
  2. package/package.json +26 -24
package/README.md CHANGED
@@ -3,19 +3,77 @@
3
3
  Shared internal/host utilities for Staffbase widgets. Tree-shakeable subpath
4
4
  modules; import only what you use.
5
5
 
6
+ ## Install
7
+
8
+ ```bash
9
+ pnpm add @favish/staffbase-utils
10
+ ```
11
+
12
+ Widgets that enforce a `minimumReleaseAge` supply-chain cooldown should exempt the
13
+ `@favish/*` scope so freshly published versions install immediately. In the
14
+ widget's `pnpm-workspace.yaml`:
15
+
16
+ ```yaml
17
+ minimumReleaseAge: 1440
18
+ minimumReleaseAgeExclude:
19
+ - '@favish/*'
20
+ ```
21
+
6
22
  ## Modules
7
23
 
8
- - `@favish/staffbase-utils/log` `logError`, `logWarn`, `logDebug`, `setLoggingEnabled`
24
+ | Subpath | Exports |
25
+ | --- | --- |
26
+ | `@favish/staffbase-utils/log` | `logError`, `logWarn`, `logDebug`, `setLoggingEnabled` |
27
+
28
+ More modules (`/env`, `/device`, `/html`, `/links`, `/widgets`) are added per the
29
+ delivery roadmap; each is its own subpath so consumers only bundle what they import.
9
30
 
10
31
  ## Logging
11
32
 
12
- The library never reads env flags directly (webview-safe). Enable console output
13
- once at widget startup with your own flag:
33
+ The library never reads env flags directly (webview-safe: a bundled `process.env`
34
+ reference would crash inside Staffbase mobile webviews). Enable console output once
35
+ at widget startup with your own flag:
14
36
 
15
37
  ```ts
16
38
  import { setLoggingEnabled } from '@favish/staffbase-utils/log'
17
39
 
18
40
  setLoggingEnabled(import.meta.env.VITE_SHOW_CONSOLE_ERRORS === 'true')
41
+ // or, for REACT_APP_-style widgets:
42
+ // setLoggingEnabled(process.env.REACT_APP_SHOW_CONSOLE_ERRORS === 'true')
43
+ ```
44
+
45
+ Disabled by default, so production stays silent. `logError`/`logWarn`/`logDebug`
46
+ forward to the matching `console` method only while enabled.
47
+
48
+ ## Releasing
49
+
50
+ Publishing runs through GitHub Actions with npm **Trusted Publishing (OIDC)** — no
51
+ tokens, no OTP — same as `@favish/staffbase-drawer` and `@favish/staffbase-cli`.
52
+
53
+ Trigger the `Release` workflow (`.github/workflows/release.yml`) manually and pick a
54
+ bump type:
55
+
56
+ ```bash
57
+ gh workflow run release.yml -f release_type=patch # or minor / major / none
58
+ ```
59
+
60
+ (or run it from the GitHub Actions tab). The workflow runs the quality gate
61
+ (type-check, lint, test, build), bumps + tags the version, publishes to npm with
62
+ provenance, and pushes the version commit + tag back to `main`. Use
63
+ `release_type=none` to publish the current `package.json` version as-is.
64
+
65
+ CI (`.github/workflows/ci.yml`) runs the same quality gate on every push and PR to
66
+ `main`.
67
+
68
+ ## Development
69
+
70
+ ```bash
71
+ pnpm install # installs deps and runs the full verify+build via `prepare`
72
+ pnpm test # jest
73
+ pnpm run type-check
74
+ pnpm run lint
75
+ pnpm run build # vite library build -> dist/
19
76
  ```
20
77
 
21
- Disabled by default, so production stays silent.
78
+ Conventions: one exported symbol per file; types under `src/types/`; ESM + CJS
79
+ outputs per module (`*.es.mjs` / `*.cjs.js`) with generated `.d.ts`.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@favish/staffbase-utils",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Shared internal/host utilities for Staffbase widgets",
5
5
  "author": "Favish <dev@favish.com>",
6
- "packageManager": "pnpm@11.5.0",
7
6
  "license": "UNLICENSED",
8
- "type": "module",
9
- "files": ["dist"],
7
+ "files": [
8
+ "dist"
9
+ ],
10
10
  "exports": {
11
11
  "./log": {
12
12
  "types": "./dist/src/log/index.d.ts",
@@ -14,25 +14,9 @@
14
14
  "require": "./dist/log.cjs.js"
15
15
  }
16
16
  },
17
- "scripts": {
18
- "build": "vite build",
19
- "check:all": "pnpm run format && pnpm run lint:fix && pnpm run type-check && pnpm run test",
20
- "format": "prettier --write \"src/**/*\" --list-different",
21
- "lint": "eslint ./src",
22
- "lint:fix": "eslint ./src --fix",
23
- "prepare": "pnpm run format && pnpm run type-check && pnpm run lint:fix && pnpm run build",
24
- "prepublishOnly": "pnpm run test",
25
- "publish:major": "pnpm run prepare && pnpm version major && pnpm publish",
26
- "publish:minor": "pnpm run prepare && pnpm version minor && pnpm publish",
27
- "publish:patch": "pnpm run prepare && pnpm version patch && pnpm publish",
28
- "test": "jest",
29
- "test:watch": "jest --watch",
30
- "type-check": "tsc --pretty --noEmit",
31
- "type-check:watch": "tsc --pretty --noEmit --watch"
32
- },
33
17
  "repository": {
34
18
  "type": "git",
35
- "url": "https://github.com/favish/staffbase-utils"
19
+ "url": "git+https://github.com/favish/staffbase-utils.git"
36
20
  },
37
21
  "publishConfig": {
38
22
  "registry": "https://registry.npmjs.org/",
@@ -43,8 +27,12 @@
43
27
  "react-dom": "^18.0.0 || ^19.0.0"
44
28
  },
45
29
  "peerDependenciesMeta": {
46
- "react": { "optional": true },
47
- "react-dom": { "optional": true }
30
+ "react": {
31
+ "optional": true
32
+ },
33
+ "react-dom": {
34
+ "optional": true
35
+ }
48
36
  },
49
37
  "devDependencies": {
50
38
  "@eslint/eslintrc": "^3.3.5",
@@ -69,5 +57,19 @@
69
57
  "typescript-eslint": "^8.60.0",
70
58
  "vite": "^8.0.14",
71
59
  "vite-plugin-dts": "^5.0.1"
60
+ },
61
+ "scripts": {
62
+ "build": "vite build",
63
+ "check:all": "pnpm run format && pnpm run lint:fix && pnpm run type-check && pnpm run test",
64
+ "format": "prettier --write \"src/**/*\" --list-different",
65
+ "lint": "eslint ./src",
66
+ "lint:fix": "eslint ./src --fix",
67
+ "publish:major": "pnpm run prepare && pnpm version major && pnpm publish",
68
+ "publish:minor": "pnpm run prepare && pnpm version minor && pnpm publish",
69
+ "publish:patch": "pnpm run prepare && pnpm version patch && pnpm publish",
70
+ "test": "jest",
71
+ "test:watch": "jest --watch",
72
+ "type-check": "tsc --pretty --noEmit",
73
+ "type-check:watch": "tsc --pretty --noEmit --watch"
72
74
  }
73
- }
75
+ }