codify-plugin-lib 1.0.152 → 1.0.153
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,9 +1,14 @@
|
|
|
1
1
|
import isObjectsEqual from 'lodash.isequal';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { areArraysEqual, tildify, untildify } from '../utils/utils.js';
|
|
3
|
+
import { areArraysEqual, tildify, unhome, untildify } from '../utils/utils.js';
|
|
4
4
|
const ParameterEqualsDefaults = {
|
|
5
5
|
'boolean': (a, b) => Boolean(a) === Boolean(b),
|
|
6
|
-
'directory': (a, b) =>
|
|
6
|
+
'directory': (a, b) => {
|
|
7
|
+
const notCaseSensitive = process.platform === 'darwin';
|
|
8
|
+
const transformedA = path.resolve(unhome(untildify(notCaseSensitive ? String(a).toLowerCase() : String(a))));
|
|
9
|
+
const transformedB = path.resolve(unhome(untildify(notCaseSensitive ? String(b).toLowerCase() : String(b))));
|
|
10
|
+
return transformedA === transformedB;
|
|
11
|
+
},
|
|
7
12
|
'number': (a, b) => Number(a) === Number(b),
|
|
8
13
|
'string': (a, b) => String(a) === String(b),
|
|
9
14
|
'version': (desired, current) => String(current).includes(String(desired)),
|
|
@@ -48,7 +53,7 @@ export function resolveFnFromEqualsFnOrString(fnOrString) {
|
|
|
48
53
|
}
|
|
49
54
|
const ParameterTransformationDefaults = {
|
|
50
55
|
'directory': {
|
|
51
|
-
to: (a) => path.resolve(untildify(String(a))),
|
|
56
|
+
to: (a) => path.resolve(unhome(untildify(String(a)))),
|
|
52
57
|
from: (a) => tildify(String(a)),
|
|
53
58
|
},
|
|
54
59
|
'string': {
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export declare function splitUserConfig<T extends StringIndexedObject>(config: R
|
|
|
7
7
|
export declare function setsEqual(set1: Set<unknown>, set2: Set<unknown>): boolean;
|
|
8
8
|
export declare function untildify(pathWithTilde: string): string;
|
|
9
9
|
export declare function tildify(pathWithTilde: string): string;
|
|
10
|
+
export declare function unhome(pathWithHome: string): string;
|
|
10
11
|
export declare function areArraysEqual(isElementEqual: ((desired: unknown, current: unknown) => boolean) | undefined, desired: unknown, current: unknown): boolean;
|
package/dist/utils/utils.js
CHANGED
|
@@ -25,6 +25,9 @@ export function untildify(pathWithTilde) {
|
|
|
25
25
|
export function tildify(pathWithTilde) {
|
|
26
26
|
return homeDirectory ? pathWithTilde.replace(homeDirectory, '~') : pathWithTilde;
|
|
27
27
|
}
|
|
28
|
+
export function unhome(pathWithHome) {
|
|
29
|
+
return pathWithHome.includes('$HOME') ? pathWithHome.replaceAll('$HOME', os.homedir()) : pathWithHome;
|
|
30
|
+
}
|
|
28
31
|
export function areArraysEqual(isElementEqual, desired, current) {
|
|
29
32
|
if (!desired || !current) {
|
|
30
33
|
return false;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import isObjectsEqual from 'lodash.isequal'
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
|
|
6
6
|
import { ArrayStatefulParameter, StatefulParameter } from '../stateful-parameter/stateful-parameter.js';
|
|
7
|
-
import { areArraysEqual, tildify, untildify } from '../utils/utils.js';
|
|
7
|
+
import { areArraysEqual, tildify, unhome, untildify } from '../utils/utils.js';
|
|
8
8
|
|
|
9
9
|
export interface InputTransformation {
|
|
10
10
|
to: (input: any) => Promise<any> | any;
|
|
@@ -302,7 +302,13 @@ export interface StatefulParameterSetting extends DefaultParameterSetting {
|
|
|
302
302
|
|
|
303
303
|
const ParameterEqualsDefaults: Partial<Record<ParameterSettingType, (a: unknown, b: unknown) => boolean>> = {
|
|
304
304
|
'boolean': (a: unknown, b: unknown) => Boolean(a) === Boolean(b),
|
|
305
|
-
'directory': (a: unknown, b: unknown) =>
|
|
305
|
+
'directory': (a: unknown, b: unknown) => {
|
|
306
|
+
const notCaseSensitive = process.platform === 'darwin';
|
|
307
|
+
const transformedA = path.resolve(unhome(untildify(notCaseSensitive ? String(a).toLowerCase() : String(a))))
|
|
308
|
+
const transformedB = path.resolve(unhome(untildify(notCaseSensitive ? String(b).toLowerCase() : String(b))))
|
|
309
|
+
|
|
310
|
+
return transformedA === transformedB;
|
|
311
|
+
},
|
|
306
312
|
'number': (a: unknown, b: unknown) => Number(a) === Number(b),
|
|
307
313
|
'string': (a: unknown, b: unknown) => String(a) === String(b),
|
|
308
314
|
'version': (desired: unknown, current: unknown) => String(current).includes(String(desired)),
|
|
@@ -362,7 +368,7 @@ export function resolveFnFromEqualsFnOrString(
|
|
|
362
368
|
|
|
363
369
|
const ParameterTransformationDefaults: Partial<Record<ParameterSettingType, InputTransformation>> = {
|
|
364
370
|
'directory': {
|
|
365
|
-
to: (a: unknown) => path.resolve(untildify(String(a))),
|
|
371
|
+
to: (a: unknown) => path.resolve(unhome(untildify(String(a)))),
|
|
366
372
|
from: (a: unknown) => tildify(String(a)),
|
|
367
373
|
},
|
|
368
374
|
'string': {
|
package/src/utils/utils.ts
CHANGED
|
@@ -37,6 +37,10 @@ export function tildify(pathWithTilde: string) {
|
|
|
37
37
|
return homeDirectory ? pathWithTilde.replace(homeDirectory, '~') : pathWithTilde;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export function unhome(pathWithHome: string): string {
|
|
41
|
+
return pathWithHome.includes('$HOME') ? pathWithHome.replaceAll('$HOME', os.homedir()) : pathWithHome;
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
export function areArraysEqual(
|
|
41
45
|
isElementEqual: ((desired: unknown, current: unknown) => boolean) | undefined,
|
|
42
46
|
desired: unknown,
|