@stonyx/utils 0.2.3-alpha.3 → 0.2.3-alpha.4
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.
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Project Structure
|
|
2
2
|
|
|
3
|
+
## Index
|
|
4
|
+
|
|
5
|
+
- [Overview](#overview)
|
|
6
|
+
- [Tech Stack](#tech-stack)
|
|
7
|
+
- [File Structure](#file-structure)
|
|
8
|
+
- [Package Exports](#package-exports)
|
|
9
|
+
- [Module Documentation](#module-documentation)
|
|
10
|
+
- [date.js](#srcdate.js)
|
|
11
|
+
- [file.js](#srcfile.js)
|
|
12
|
+
- [object.js](#srcobject.js)
|
|
13
|
+
- [plurarize.js](#srcplurarize.js)
|
|
14
|
+
- [promise.js](#srcpromise.js)
|
|
15
|
+
- [prompt.js](#srcprompt.js)
|
|
16
|
+
- [string.js](#srcstring.js)
|
|
17
|
+
- [Dependencies](#dependencies)
|
|
18
|
+
- [Test Patterns](#test-patterns)
|
|
19
|
+
- [CI/CD](#cicd)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
3
23
|
## Overview
|
|
4
24
|
|
|
5
25
|
`@stonyx/utils` is a utilities module for the Stonyx Framework. It provides pure JavaScript helper functions for file system operations, object manipulation, string transformations, date handling, promises, and interactive CLI prompts.
|
|
@@ -26,7 +46,6 @@
|
|
|
26
46
|
stonyx-utils/
|
|
27
47
|
.claude/ # Claude project memory
|
|
28
48
|
project-structure.md # This file
|
|
29
|
-
improvements.md # Known issues and improvement ideas
|
|
30
49
|
.github/
|
|
31
50
|
workflows/
|
|
32
51
|
ci.yml # CI on PRs to dev/main (reusable workflow)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
name: Publish to NPM
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
+
repository_dispatch:
|
|
5
|
+
types: [cascade-publish]
|
|
4
6
|
workflow_dispatch:
|
|
5
7
|
inputs:
|
|
6
8
|
version-type:
|
|
@@ -17,10 +19,14 @@ on:
|
|
|
17
19
|
type: string
|
|
18
20
|
pull_request:
|
|
19
21
|
types: [opened, synchronize, reopened]
|
|
20
|
-
branches: [main
|
|
22
|
+
branches: [main]
|
|
21
23
|
push:
|
|
22
24
|
branches: [main]
|
|
23
25
|
|
|
26
|
+
concurrency:
|
|
27
|
+
group: ${{ github.event_name == 'repository_dispatch' && 'cascade-update' || format('publish-{0}', github.ref) }}
|
|
28
|
+
cancel-in-progress: false
|
|
29
|
+
|
|
24
30
|
permissions:
|
|
25
31
|
contents: write
|
|
26
32
|
id-token: write
|
|
@@ -28,8 +34,18 @@ permissions:
|
|
|
28
34
|
|
|
29
35
|
jobs:
|
|
30
36
|
publish:
|
|
37
|
+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
31
38
|
uses: abofs/stonyx-workflows/.github/workflows/npm-publish.yml@main
|
|
32
39
|
with:
|
|
33
40
|
version-type: ${{ github.event.inputs.version-type }}
|
|
34
41
|
custom-version: ${{ github.event.inputs.custom-version }}
|
|
42
|
+
cascade-source: ${{ github.event.client_payload.source_package || '' }}
|
|
43
|
+
secrets: inherit
|
|
44
|
+
|
|
45
|
+
cascade:
|
|
46
|
+
needs: publish
|
|
47
|
+
uses: abofs/stonyx-workflows/.github/workflows/cascade.yml@main
|
|
48
|
+
with:
|
|
49
|
+
package-name: ${{ needs.publish.outputs.package-name }}
|
|
50
|
+
published-version: ${{ needs.publish.outputs.published-version }}
|
|
35
51
|
secrets: inherit
|
package/package.json
CHANGED
package/.claude/improvements.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# Improvements
|
|
2
|
-
|
|
3
|
-
Known code issues and suggested fixes for `@stonyx/utils`.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1. Filename typo: `plurarize.js` should be `pluralize.js`
|
|
8
|
-
|
|
9
|
-
**Files affected:**
|
|
10
|
-
- `src/plurarize.js` (source)
|
|
11
|
-
- `test/unit/string/plurarize-test.js` (test)
|
|
12
|
-
- `src/string.js` (re-export references `./plurarize.js`)
|
|
13
|
-
|
|
14
|
-
**Details:**
|
|
15
|
-
The filename `plurarize.js` is missing the second "l" — it should be `pluralize.js`. The typo is propagated to the test file (`plurarize-test.js`) and the re-export in `src/string.js`:
|
|
16
|
-
|
|
17
|
-
```js
|
|
18
|
-
// src/string.js, line 35
|
|
19
|
-
export { default as pluralize } from './plurarize.js';
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
**Suggested fix:**
|
|
23
|
-
Rename `src/plurarize.js` to `src/pluralize.js`, rename `test/unit/string/plurarize-test.js` to `test/unit/string/pluralize-test.js`, and update the import path in `src/string.js`.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## 2. Self-referential package imports in `src/file.js`
|
|
28
|
-
|
|
29
|
-
**File:** `src/file.js`
|
|
30
|
-
|
|
31
|
-
**Details:**
|
|
32
|
-
`src/file.js` imports from its own package using the published package specifier:
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
// src/file.js, lines 1-3
|
|
36
|
-
import { getTimestamp } from '@stonyx/utils/date';
|
|
37
|
-
import { kebabCaseToCamelCase } from '@stonyx/utils/string';
|
|
38
|
-
import { objToJson } from '@stonyx/utils/object';
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
These self-referential imports resolve correctly in local development (Node respects the `exports` map for the current package) but are fragile for a published package — they rely on Node's self-referencing behavior, which can break in certain bundler or monorepo resolution scenarios.
|
|
42
|
-
|
|
43
|
-
**Suggested fix:**
|
|
44
|
-
Use relative imports instead:
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
import { getTimestamp } from './date.js';
|
|
48
|
-
import { kebabCaseToCamelCase } from './string.js';
|
|
49
|
-
import { objToJson } from './object.js';
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## 3. `get()` uses `console.error` instead of throwing
|
|
55
|
-
|
|
56
|
-
**File:** `src/object.js`, lines 42-44
|
|
57
|
-
|
|
58
|
-
**Details:**
|
|
59
|
-
The `get()` function uses `console.error` and returns `undefined` for invalid arguments:
|
|
60
|
-
|
|
61
|
-
```js
|
|
62
|
-
export function get(obj, path) {
|
|
63
|
-
if (arguments.length !== 2) return console.error('Get must be called with two arguments; an object and a property key.');
|
|
64
|
-
if (!obj) return console.error(`Cannot call get with '${path}' on an undefined object.`);
|
|
65
|
-
if (typeof path !== 'string') return console.error('The path provided to get must be a string.');
|
|
66
|
-
...
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
This is inconsistent with other functions in the same module — `mergeObject` throws `new Error('Cannot merge arrays.')` and `getOrSet` throws `new Error('First argument to getOrSet must be a Map.')`. The `console.error` approach silently returns `undefined` (the return value of `console.error`), making bugs harder to catch in calling code.
|
|
71
|
-
|
|
72
|
-
**Suggested fix:**
|
|
73
|
-
Replace `console.error` calls with `throw new Error(...)` to match the error-handling pattern used by `mergeObject` and `getOrSet`. This would also require updating the tests in `test/unit/object/get-test.js` to use `assert.throws` instead of spying on `console.error`.
|