@sprucelabs/spruce-skill-utils 32.1.0 → 32.1.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.
@@ -75,7 +75,7 @@ export default class SettingsService {
75
75
  return this.settings;
76
76
  }
77
77
  getSettingsPath() {
78
- const isInGoProject = diskUtil.doesFileExist(diskUtil.resolvePath(this.cwd, 'go.mod'));
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
  }
@@ -73,3 +73,4 @@ export interface PersonWithToken {
73
73
  token: string;
74
74
  isLoggedIn?: boolean | undefined | null;
75
75
  }
76
+ export type ProjectLanguage = 'ts' | 'go' | 'unknown' | 'js';
@@ -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);
@@ -78,7 +78,7 @@ class SettingsService {
78
78
  return this.settings;
79
79
  }
80
80
  getSettingsPath() {
81
- const isInGoProject = disk_utility_1.default.doesFileExist(disk_utility_1.default.resolvePath(this.cwd, 'go.mod'));
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
  }
@@ -73,3 +73,4 @@ export interface PersonWithToken {
73
73
  token: string;
74
74
  isLoggedIn?: boolean | undefined | null;
75
75
  }
76
+ export type ProjectLanguage = 'ts' | 'go' | 'unknown' | 'js';
@@ -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.0",
6
+ "version": "32.1.1",
7
7
  "skill": {
8
8
  "namespace": "skill-utils",
9
9
  "upgradeIgnoreList": [