@sprucelabs/spruce-skill-utils 32.1.0 → 32.1.2
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/build/esm/services/SettingsService.js +2 -2
- package/build/esm/types/skill.types.d.ts +1 -0
- package/build/esm/utilities/disk.utility.d.ts +2 -0
- package/build/esm/utilities/disk.utility.js +11 -0
- package/build/esm/utilities/version.utility.js +0 -2
- package/build/services/SettingsService.js +2 -2
- package/build/types/skill.types.d.ts +1 -0
- package/build/utilities/disk.utility.d.ts +2 -0
- package/build/utilities/disk.utility.js +11 -0
- package/build/utilities/version.utility.js +0 -2
- package/package.json +3 -3
|
@@ -62,9 +62,9 @@ export default class SettingsService {
|
|
|
62
62
|
this.settings = undefined;
|
|
63
63
|
}
|
|
64
64
|
loadSettings() {
|
|
65
|
-
const path = this.getSettingsPath();
|
|
66
65
|
if (!this.settings) {
|
|
67
66
|
try {
|
|
67
|
+
const path = this.getSettingsPath();
|
|
68
68
|
const contents = diskUtil.readFile(path);
|
|
69
69
|
this.settings = JSON.parse(contents);
|
|
70
70
|
}
|
|
@@ -75,7 +75,7 @@ export default class SettingsService {
|
|
|
75
75
|
return this.settings;
|
|
76
76
|
}
|
|
77
77
|
getSettingsPath() {
|
|
78
|
-
const isInGoProject = diskUtil.
|
|
78
|
+
const isInGoProject = diskUtil.detectProjectLanguage(this.cwd) === 'go';
|
|
79
79
|
if (isInGoProject) {
|
|
80
80
|
return diskUtil.resolvePath(this.cwd, HASH_SPRUCE_DIR_NAME, this.fileName);
|
|
81
81
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProjectLanguage } from '../types/skill.types';
|
|
1
2
|
export interface CreateFile {
|
|
2
3
|
/** The relative path from the cwd, without a leading forward slash */
|
|
3
4
|
relativePath: string;
|
|
@@ -20,6 +21,7 @@ declare const diskUtil: {
|
|
|
20
21
|
isFile(target: string): boolean;
|
|
21
22
|
doesDirExist(target: string): boolean;
|
|
22
23
|
resolveHashSprucePath(cwd: string, ...filePath: string[]): string;
|
|
24
|
+
detectProjectLanguage(cwd: string): ProjectLanguage;
|
|
23
25
|
doesHashSprucePathExist(cwd: string, ...filePath: string[]): boolean;
|
|
24
26
|
resolveBuiltHashSprucePath(cwd: string, ...filePath: string[]): string;
|
|
25
27
|
doesBuiltHashSprucePathExist(cwd: string, ...filePath: string[]): boolean;
|
|
@@ -103,6 +103,17 @@ const diskUtil = {
|
|
|
103
103
|
} while (parts.length > 0);
|
|
104
104
|
throw new Error(`.spruce directory not found at ${cwd}`);
|
|
105
105
|
},
|
|
106
|
+
detectProjectLanguage(cwd) {
|
|
107
|
+
const isInGoProject = this.doesDirExist(this.resolvePath(cwd, 'go.mod'));
|
|
108
|
+
if (isInGoProject) {
|
|
109
|
+
return 'go';
|
|
110
|
+
}
|
|
111
|
+
const isInTypescript = this.doesFileExist(this.resolvePath(cwd, 'tsconfig.json'));
|
|
112
|
+
if (isInTypescript) {
|
|
113
|
+
return 'ts';
|
|
114
|
+
}
|
|
115
|
+
return 'js';
|
|
116
|
+
},
|
|
106
117
|
doesHashSprucePathExist(cwd, ...filePath) {
|
|
107
118
|
try {
|
|
108
119
|
this.resolveHashSprucePath(cwd, ...filePath);
|
|
@@ -56,7 +56,6 @@ const versionUtil = {
|
|
|
56
56
|
const version = this.getAllVersions(resolved);
|
|
57
57
|
const latest = version.pop();
|
|
58
58
|
if (!latest) {
|
|
59
|
-
debugger;
|
|
60
59
|
throw new SpruceError({
|
|
61
60
|
//@ts-ignore
|
|
62
61
|
code: 'NO_VERSIONING_FOUND',
|
|
@@ -85,7 +84,6 @@ const versionUtil = {
|
|
|
85
84
|
const allDateIsh = this.getAllVersions(dirToRead);
|
|
86
85
|
const latest = allDateIsh.pop();
|
|
87
86
|
if (!latest) {
|
|
88
|
-
debugger;
|
|
89
87
|
throw new Error('no versioning found!');
|
|
90
88
|
}
|
|
91
89
|
return resolved.replace(LATEST_HANDLEBARS, latest.dirValue);
|
|
@@ -65,9 +65,9 @@ class SettingsService {
|
|
|
65
65
|
this.settings = undefined;
|
|
66
66
|
}
|
|
67
67
|
loadSettings() {
|
|
68
|
-
const path = this.getSettingsPath();
|
|
69
68
|
if (!this.settings) {
|
|
70
69
|
try {
|
|
70
|
+
const path = this.getSettingsPath();
|
|
71
71
|
const contents = disk_utility_1.default.readFile(path);
|
|
72
72
|
this.settings = JSON.parse(contents);
|
|
73
73
|
}
|
|
@@ -78,7 +78,7 @@ class SettingsService {
|
|
|
78
78
|
return this.settings;
|
|
79
79
|
}
|
|
80
80
|
getSettingsPath() {
|
|
81
|
-
const isInGoProject = disk_utility_1.default.
|
|
81
|
+
const isInGoProject = disk_utility_1.default.detectProjectLanguage(this.cwd) === 'go';
|
|
82
82
|
if (isInGoProject) {
|
|
83
83
|
return disk_utility_1.default.resolvePath(this.cwd, constants_1.HASH_SPRUCE_DIR_NAME, this.fileName);
|
|
84
84
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProjectLanguage } from '../types/skill.types';
|
|
1
2
|
export interface CreateFile {
|
|
2
3
|
/** The relative path from the cwd, without a leading forward slash */
|
|
3
4
|
relativePath: string;
|
|
@@ -20,6 +21,7 @@ declare const diskUtil: {
|
|
|
20
21
|
isFile(target: string): boolean;
|
|
21
22
|
doesDirExist(target: string): boolean;
|
|
22
23
|
resolveHashSprucePath(cwd: string, ...filePath: string[]): string;
|
|
24
|
+
detectProjectLanguage(cwd: string): ProjectLanguage;
|
|
23
25
|
doesHashSprucePathExist(cwd: string, ...filePath: string[]): boolean;
|
|
24
26
|
resolveBuiltHashSprucePath(cwd: string, ...filePath: string[]): string;
|
|
25
27
|
doesBuiltHashSprucePathExist(cwd: string, ...filePath: string[]): boolean;
|
|
@@ -97,6 +97,17 @@ const diskUtil = {
|
|
|
97
97
|
} while (parts.length > 0);
|
|
98
98
|
throw new Error(`.spruce directory not found at ${cwd}`);
|
|
99
99
|
},
|
|
100
|
+
detectProjectLanguage(cwd) {
|
|
101
|
+
const isInGoProject = this.doesDirExist(this.resolvePath(cwd, 'go.mod'));
|
|
102
|
+
if (isInGoProject) {
|
|
103
|
+
return 'go';
|
|
104
|
+
}
|
|
105
|
+
const isInTypescript = this.doesFileExist(this.resolvePath(cwd, 'tsconfig.json'));
|
|
106
|
+
if (isInTypescript) {
|
|
107
|
+
return 'ts';
|
|
108
|
+
}
|
|
109
|
+
return 'js';
|
|
110
|
+
},
|
|
100
111
|
doesHashSprucePathExist(cwd, ...filePath) {
|
|
101
112
|
try {
|
|
102
113
|
this.resolveHashSprucePath(cwd, ...filePath);
|
|
@@ -62,7 +62,6 @@ const versionUtil = {
|
|
|
62
62
|
const version = this.getAllVersions(resolved);
|
|
63
63
|
const latest = version.pop();
|
|
64
64
|
if (!latest) {
|
|
65
|
-
debugger;
|
|
66
65
|
throw new SpruceError_1.default({
|
|
67
66
|
//@ts-ignore
|
|
68
67
|
code: 'NO_VERSIONING_FOUND',
|
|
@@ -91,7 +90,6 @@ const versionUtil = {
|
|
|
91
90
|
const allDateIsh = this.getAllVersions(dirToRead);
|
|
92
91
|
const latest = allDateIsh.pop();
|
|
93
92
|
if (!latest) {
|
|
94
|
-
debugger;
|
|
95
93
|
throw new Error('no versioning found!');
|
|
96
94
|
}
|
|
97
95
|
return resolved.replace(constants_1.LATEST_HANDLEBARS, latest.dirValue);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "32.1.
|
|
6
|
+
"version": "32.1.2",
|
|
7
7
|
"skill": {
|
|
8
8
|
"namespace": "skill-utils",
|
|
9
9
|
"upgradeIgnoreList": [
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"@sprucelabs/resolve-path-aliases": "^3.0.28",
|
|
73
73
|
"@sprucelabs/semantic-release": "^5.0.2",
|
|
74
74
|
"@sprucelabs/test": "^10.0.24",
|
|
75
|
-
"@sprucelabs/test-utils": "^6.0.
|
|
75
|
+
"@sprucelabs/test-utils": "^6.0.107",
|
|
76
76
|
"@types/fs-extra": "^11.0.4",
|
|
77
77
|
"@types/inflection": "^2.0.0",
|
|
78
78
|
"@types/lodash": "^4.17.20",
|
|
79
|
-
"@types/node": "^24.8.
|
|
79
|
+
"@types/node": "^24.8.1",
|
|
80
80
|
"chokidar-cli": "^3.0.0",
|
|
81
81
|
"eslint": "^9.37.0",
|
|
82
82
|
"eslint-config-spruce": "^11.2.26",
|