create-node-lib 2.17.0 → 2.17.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.17.1](https://github.com/lirantal/create-node-lib/compare/v2.17.0...v2.17.1) (2026-05-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add initialization script for development environment ([40cfb83](https://github.com/lirantal/create-node-lib/commit/40cfb8357638c5d78f88359663f7a785118ad7d9))
7
+
1
8
  # [2.17.0](https://github.com/lirantal/create-node-lib/compare/v2.16.7...v2.17.0) (2026-05-03)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-node-lib",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "description": "Scaffolding out a Node.js library module",
5
5
  "bin": "./bin/cli.js",
6
6
  "engines": {
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env bash
2
+ # initialize: runs on host before container create/start (initializeCommand).
3
+ # Prepares .env.development and, when possible, injects OP_SERVICE_ACCOUNT_TOKEN from 1Password.
4
+
5
+ set -euo pipefail
6
+
7
+ WORKSPACE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
8
+ ENV_FILE="${WORKSPACE_DIR}/.env.development"
9
+ OP_TOKEN_REFERENCE="op://Private/1Password op CLI Service Account for DevContainers/password"
10
+
11
+ main() {
12
+ ensure_env_file_exists
13
+ maybe_inject_1password_service_account_token
14
+ }
15
+
16
+ ensure_env_file_exists() {
17
+ if [[ ! -f "${ENV_FILE}" ]]; then
18
+ : > "${ENV_FILE}"
19
+ fi
20
+ }
21
+
22
+ maybe_inject_1password_service_account_token() {
23
+ local token
24
+
25
+ if ! command -v op >/dev/null 2>&1; then
26
+ echo "initialize.sh: op CLI not found; leaving ${ENV_FILE} unchanged."
27
+ return 0
28
+ fi
29
+
30
+ if ! token="$(op read "${OP_TOKEN_REFERENCE}" 2>/dev/null)"; then
31
+ echo "initialize.sh: could not read OP service token from 1Password; leaving ${ENV_FILE} unchanged."
32
+ return 0
33
+ fi
34
+
35
+ if [[ -z "${token}" ]]; then
36
+ echo "initialize.sh: OP service token is empty; leaving ${ENV_FILE} unchanged."
37
+ return 0
38
+ fi
39
+
40
+ upsert_env_var "OP_SERVICE_ACCOUNT_TOKEN" "${token}"
41
+ }
42
+
43
+ upsert_env_var() {
44
+ local key="$1"
45
+ local value="$2"
46
+ local tmp_file
47
+
48
+ tmp_file="$(mktemp)"
49
+ awk -F= -v k="${key}" '$1 != k' "${ENV_FILE}" > "${tmp_file}"
50
+ printf '%s=%s\n' "${key}" "${value}" >> "${tmp_file}"
51
+ mv "${tmp_file}" "${ENV_FILE}"
52
+ }
53
+
54
+ main "$@"