@cocreate/utils 1.40.1 → 1.41.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/.github/workflows/automated.yml +5 -5
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/index.js +56 -0
|
@@ -22,13 +22,13 @@ jobs:
|
|
|
22
22
|
runs-on: ubuntu-latest
|
|
23
23
|
steps:
|
|
24
24
|
- name: Checkout
|
|
25
|
-
uses: actions/checkout@
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
26
|
- name: Setup Node.js
|
|
27
|
-
uses: actions/setup-node@
|
|
27
|
+
uses: actions/setup-node@v4
|
|
28
28
|
with:
|
|
29
|
-
node-version:
|
|
29
|
+
node-version: 22 # Required for the latest semantic-release plugins
|
|
30
30
|
- name: Semantic Release
|
|
31
|
-
uses: cycjimmy/semantic-release-action@
|
|
31
|
+
uses: cycjimmy/semantic-release-action@v4 # Update to v4 for better Node 20+ support
|
|
32
32
|
id: semantic
|
|
33
33
|
with:
|
|
34
34
|
extra_plugins: |
|
|
@@ -36,7 +36,7 @@ jobs:
|
|
|
36
36
|
@semantic-release/git
|
|
37
37
|
@semantic-release/github
|
|
38
38
|
env:
|
|
39
|
-
GITHUB_TOKEN: "${{ secrets.
|
|
39
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # Use the built-in token if possible
|
|
40
40
|
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
41
41
|
outputs:
|
|
42
42
|
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.41.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.41.0...v1.41.1) (2026-02-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update worklow ([5a12bfc](https://github.com/CoCreate-app/CoCreate-utils/commit/5a12bfc15a3be0161592ad041293b876dd92d186))
|
|
7
|
+
|
|
8
|
+
# [1.41.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.40.1...v1.41.0) (2025-11-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add uid function to generate UUIDs with customizable length ([7103971](https://github.com/CoCreate-app/CoCreate-utils/commit/71039712fe19d37bacdd5cd23db3366dd6b16ccb))
|
|
14
|
+
|
|
1
15
|
## [1.40.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.40.0...v1.40.1) (2025-10-10)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -67,6 +67,46 @@
|
|
|
67
67
|
return depth > 0 ? "../".repeat(depth) : "./";
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// function getRelativePath(path) {
|
|
71
|
+
// const isBrowser = typeof window !== 'undefined';
|
|
72
|
+
|
|
73
|
+
// // If no path provided, use window.location.pathname
|
|
74
|
+
// if (!path && isBrowser) {
|
|
75
|
+
// path = window.location.pathname;
|
|
76
|
+
|
|
77
|
+
// // FIX: Only remove the end segment if it looks like a file (has an extension like .html)
|
|
78
|
+
// // This prevents stripping valid routes like /dashboard
|
|
79
|
+
// if (/\.[^/]+$/.test(path)) {
|
|
80
|
+
// path = path.replace(/\/[^\/]*$/, "");
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
83
|
+
|
|
84
|
+
// // For localhost/127.0.0.1, remove everything up to and including the first '/src'
|
|
85
|
+
// if (
|
|
86
|
+
// isBrowser &&
|
|
87
|
+
// (window.location.hostname === "localhost" ||
|
|
88
|
+
// window.location.hostname === "127.0.0.1")
|
|
89
|
+
// ) {
|
|
90
|
+
// const srcIndex = path.indexOf("/src");
|
|
91
|
+
// if (srcIndex !== -1) {
|
|
92
|
+
// // If path is "/BeautySalon/src", this returns ""
|
|
93
|
+
// path = path.slice(srcIndex + 4);
|
|
94
|
+
// }
|
|
95
|
+
// }
|
|
96
|
+
|
|
97
|
+
// // Handle the empty string case here:
|
|
98
|
+
// // "" does not end with "/", so it adds one -> "/"
|
|
99
|
+
// if (!path || !path.endsWith("/")) {
|
|
100
|
+
// path = (path || "") + "/";
|
|
101
|
+
// }
|
|
102
|
+
|
|
103
|
+
// // "/" splits to ['', ''], filter removes them -> length is 0
|
|
104
|
+
// let depth = path.split("/").filter(Boolean).length;
|
|
105
|
+
|
|
106
|
+
// // 0 depth returns "./"
|
|
107
|
+
// return depth > 0 ? "../".repeat(depth) : "./";
|
|
108
|
+
// }
|
|
109
|
+
|
|
70
110
|
/**
|
|
71
111
|
* Generates an ObjectId
|
|
72
112
|
*/
|
|
@@ -114,6 +154,21 @@
|
|
|
114
154
|
};
|
|
115
155
|
}
|
|
116
156
|
|
|
157
|
+
function uid(length = 36) {
|
|
158
|
+
let pattern = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
159
|
+
if (length > 36) {
|
|
160
|
+
length = 36; // If requested length is more than 36, set it to 36.
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let uuid = pattern.replace(/[xy]/g, function (c) {
|
|
164
|
+
var r = (Math.random() * 16) | 0;
|
|
165
|
+
var v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
166
|
+
return v.toString(16);
|
|
167
|
+
}).substring(0, length); // Truncate to the requested length.
|
|
168
|
+
|
|
169
|
+
return uuid;
|
|
170
|
+
}
|
|
171
|
+
|
|
117
172
|
function checkValue(value) {
|
|
118
173
|
if (/{{\s*([\w\W]+)\s*}}/g.test(value)) return false;
|
|
119
174
|
else return true;
|
|
@@ -1286,6 +1341,7 @@
|
|
|
1286
1341
|
return {
|
|
1287
1342
|
getRelativePath,
|
|
1288
1343
|
ObjectId,
|
|
1344
|
+
uid,
|
|
1289
1345
|
checkValue,
|
|
1290
1346
|
isValidDate,
|
|
1291
1347
|
dotNotationToObject,
|