my-gadgetry 1.0.3 → 1.0.11

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.
@@ -7,3 +7,4 @@ export declare const isDate: (value: any) => boolean;
7
7
  export declare const isUrlString: (value: string) => boolean;
8
8
  export declare const isStringNumbers: (name: string) => boolean;
9
9
  export declare const isNumber: (value: any, allowString?: boolean) => boolean;
10
+ export declare const isJson: (str: string) => boolean;
@@ -26,3 +26,15 @@ export const isNumber = (value, allowString = false) => {
26
26
  }
27
27
  return false;
28
28
  };
29
+ export const isJson = (str) => {
30
+ if (!isString(str)) {
31
+ return false;
32
+ }
33
+ try {
34
+ const result = JSON.parse(str);
35
+ return isString(result) || isObject(result);
36
+ }
37
+ catch (err) {
38
+ return false;
39
+ }
40
+ };
@@ -4,10 +4,8 @@ import { cleanDirectory } from './clean-directories.js';
4
4
  export const writePackageJson = (prefix, author, name, outputDir, aliases, ignoreDirectory = '') => {
5
5
  for (const alias of aliases) {
6
6
  const splits = alias.split(/\//g);
7
- const outputPaths = splits.filter((dir) => dir !== ignoreDirectory);
8
- const relative = outputPaths
9
- .map(() => '..')
10
- .join('/');
7
+ const outputPaths = splits.filter(dir => dir !== ignoreDirectory);
8
+ const relative = outputPaths.map(() => '..').join('/');
11
9
  const outputPath = outputPaths.join('/');
12
10
  const pkgManifest = {
13
11
  name: `${author}/${[name, ...splits].join('-')}`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "my-gadgetry",
3
3
  "type": "module",
4
- "version": "1.0.3",
4
+ "version": "1.0.11",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "repository": {
@@ -29,17 +29,20 @@
29
29
  "tsc": "tsc -p tsconfig.publish.json && tsc-alias -p tsconfig.publish.json",
30
30
  "generate": "tsx --tsconfig ./tsconfig.zx.json ./tools/generate-alias.zx.ts",
31
31
  "ci:update-version": "tsx --tsconfig ./tsconfig.zx.json ./tools/update-version.zx.ts",
32
+
32
33
  "//--- test ---//": "",
33
34
  "test": "run-s test:*",
34
35
  "test:lint": "npm run lint",
35
36
  "test:prettier": "npm run prettier:check",
36
37
  "test:jest": "npm run jest",
38
+
37
39
  "//--- build ---//": "",
38
40
  "build": "run-s build:*",
39
41
  "build:test": "npm run test",
40
42
  "build:clean": "npm run clean",
41
43
  "build:tsc": "npm run tsc",
42
44
  "build:generate": "npm run generate",
45
+
43
46
  "//--- publish ---//": "",
44
47
  "publish:build": "run-s build:{clean,tsc,generate}"
45
48
  },
@@ -47,25 +50,25 @@
47
50
  "@actions/core": "^1.10.1",
48
51
  "@actions/exec": "^1.1.1",
49
52
  "@actions/github": "^6.0.0",
50
- "zx": "^8.0.2"
53
+ "fs-extra": "^11.2.0",
54
+ "zx": "^8.1.0"
51
55
  },
52
56
  "devDependencies": {
53
- "@babel/core": "^7.24.4",
54
- "@babel/preset-env": "^7.24.4",
57
+ "@babel/core": "^7.24.5",
58
+ "@babel/preset-env": "^7.24.5",
55
59
  "@babel/preset-typescript": "^7.24.1",
56
60
  "@eslint/js": "^8.57.0",
57
61
  "@types/jest": "^29.5.12",
58
- "@types/node": "^20.12.7",
59
- "@typescript-eslint/eslint-plugin": "^7.7.1",
60
- "@typescript-eslint/parser": "^7.7.1",
62
+ "@types/node": "^20.12.12",
63
+ "@typescript-eslint/eslint-plugin": "^7.9.0",
64
+ "@typescript-eslint/parser": "^7.9.0",
61
65
  "babel-jest": "^29.7.0",
62
66
  "eslint": "^8.57.0",
63
67
  "eslint-config-prettier": "^9.1.0",
64
68
  "eslint-import-resolver-typescript": "^3.6.1",
65
69
  "eslint-plugin-import": "^2.29.1",
66
- "eslint-plugin-jest": "^28.2.0",
67
- "eslint-plugin-unused-imports": "^3.1.0",
68
- "fs-extra": "^11.2.0",
70
+ "eslint-plugin-jest": "^28.5.0",
71
+ "eslint-plugin-unused-imports": "^3.2.0",
69
72
  "husky": "^9.0.11",
70
73
  "jest": "^29.7.0",
71
74
  "lint-staged": "^15.2.2",
@@ -73,10 +76,10 @@
73
76
  "prettier": "^3.2.5",
74
77
  "ts-jest": "^29.1.2",
75
78
  "ts-node": "^10.9.2",
76
- "tsc-alias": "^1.8.8",
77
- "tsx": "^4.7.3",
79
+ "tsc-alias": "^1.8.10",
80
+ "tsx": "^4.10.2",
78
81
  "typescript": "^5.4.5",
79
- "typescript-eslint": "^7.7.1"
82
+ "typescript-eslint": "^7.9.0"
80
83
  },
81
84
  "exports": {
82
85
  ".": "./dist/**/*.js",
@@ -34,4 +34,16 @@ export const isNumber = (value: any, allowString = false) => {
34
34
  }
35
35
  return false
36
36
  }
37
+
38
+ export const isJson = (str: string): boolean => {
39
+ if (!isString(str)) {
40
+ return false
41
+ }
42
+ try {
43
+ const result = JSON.parse(str)
44
+ return isString(result) || isObject(result)
45
+ } catch (err) {
46
+ return false
47
+ }
48
+ }
37
49
  /* eslint-enable */
@@ -4,13 +4,18 @@ import { writeJsonSync } from 'fs-extra/esm'
4
4
 
5
5
  import { cleanDirectory } from './clean-directories.js'
6
6
 
7
- export const writePackageJson = (prefix: string, author: string, name: string, outputDir: string, aliases: string[], ignoreDirectory = '') => {
7
+ export const writePackageJson = (
8
+ prefix: string,
9
+ author: string,
10
+ name: string,
11
+ outputDir: string,
12
+ aliases: string[],
13
+ ignoreDirectory = ''
14
+ ) => {
8
15
  for (const alias of aliases) {
9
16
  const splits = alias.split(/\//g)
10
- const outputPaths = splits.filter((dir) => dir !== ignoreDirectory)
11
- const relative = outputPaths
12
- .map(() => '..')
13
- .join('/')
17
+ const outputPaths = splits.filter(dir => dir !== ignoreDirectory)
18
+ const relative = outputPaths.map(() => '..').join('/')
14
19
  const outputPath = outputPaths.join('/')
15
20
  const pkgManifest = {
16
21
  name: `${author}/${[name, ...splits].join('-')}`,