codify-plugin-lib 1.0.164 → 1.0.166

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.
@@ -99,6 +99,7 @@ export class BackgroundPty {
99
99
  await this.promiseQueue.run(async () => {
100
100
  let outputBuffer = '';
101
101
  return new Promise(resolve => {
102
+ this.basePty.write('set +o history;\n');
102
103
  this.basePty.write('unset PS1;\n');
103
104
  this.basePty.write('unset PS0;\n');
104
105
  this.basePty.write('echo setup complete\\"\n');
@@ -101,7 +101,7 @@ export function resolveParameterTransformFn(parameter) {
101
101
  from(input, original) {
102
102
  return input.map((i, idx) => {
103
103
  const originalElement = Array.isArray(original)
104
- ? original.find((o) => resolveEqualsFn(parameter)(o, i)) ?? original[idx]
104
+ ? original.find((o) => resolveElementEqualsFn(parameter)(o, i)) ?? original[idx]
105
105
  : original;
106
106
  return itemTransformation.from(i, originalElement);
107
107
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.164",
3
+ "version": "1.0.166",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -123,6 +123,7 @@ export class BackgroundPty implements IPty {
123
123
  let outputBuffer = '';
124
124
 
125
125
  return new Promise(resolve => {
126
+ this.basePty.write('set +o history;\n');
126
127
  this.basePty.write('unset PS1;\n');
127
128
  this.basePty.write('unset PS0;\n')
128
129
  this.basePty.write('echo setup complete\\"\n')
@@ -10,6 +10,7 @@ import { TestConfig, testPlan, TestResource, TestStatefulParameter } from '../ut
10
10
  import { tildify, untildify } from '../utils/utils.js';
11
11
  import { ArrayStatefulParameter, StatefulParameter } from '../stateful-parameter/stateful-parameter.js';
12
12
  import { Plan } from '../plan/plan.js';
13
+ import os from 'node:os';
13
14
 
14
15
  describe('Resource tests', () => {
15
16
 
@@ -828,6 +829,107 @@ describe('Resource tests', () => {
828
829
  }
829
830
 
830
831
  const controller = new ResourceController(resource);
831
- const plan = await controller.import({ type: 'path' }, {});
832
+ await controller.import({ type: 'path' }, {});
833
+ ;
834
+ })
835
+
836
+ it('Can import and return all of the imported parameters', async () => {
837
+ const resource = new class extends TestResource {
838
+ getSettings(): ResourceSettings<any> {
839
+ return {
840
+ id: 'path',
841
+ parameterSettings: {
842
+ path: { type: 'directory' },
843
+ paths: { canModify: true, type: 'array', itemType: 'directory' },
844
+ prepend: { default: false, setting: true },
845
+ declarationsOnly: { default: false, setting: true },
846
+ },
847
+ importAndDestroy: {
848
+ refreshMapper: (input, context) => {
849
+ if (Object.keys(input).length === 0) {
850
+ return { paths: [], declarationsOnly: true };
851
+ }
852
+
853
+ return input;
854
+ }
855
+ },
856
+ allowMultiple: {
857
+ matcher: (desired, current) => {
858
+ if (desired.path) {
859
+ return desired.path === current.path;
860
+ }
861
+
862
+ const currentPaths = new Set(current.paths)
863
+ return desired.paths?.some((p) => currentPaths.has(p));
864
+ }
865
+ }
866
+ }
867
+ }
868
+
869
+ async refresh(parameters: Partial<TestConfig>): Promise<Partial<TestConfig> | null> {
870
+ return {
871
+ paths: [
872
+ `${os.homedir()}/.pyenv/bin`,
873
+ `${os.homedir()}/.bun/bin`,
874
+ `${os.homedir()}/.deno/bin`,
875
+ `${os.homedir()}/.jenv/bin`,
876
+ `${os.homedir()}/a/random/path`,
877
+ `${os.homedir()}/.nvm/.bin/2`,
878
+ `${os.homedir()}/.nvm/.bin/3`
879
+ ]
880
+ }
881
+ }
882
+ }
883
+
884
+ const oldProcessEnv = structuredClone(process.env);
885
+
886
+ process.env['PYENV_ROOT'] = `${os.homedir()}/.pyenv`
887
+ process.env['BUN_INSTALL'] = `${os.homedir()}/.bun`
888
+ process.env['DENO_INSTALL'] = `${os.homedir()}/.deno`
889
+ process.env['JENV'] = `${os.homedir()}/.jenv`
890
+ process.env['NVM_DIR'] = `${os.homedir()}/.nvm`
891
+
892
+ const controller = new ResourceController(resource);
893
+ const importResult1 = await controller.import({ type: 'path' }, {});
894
+ expect(importResult1).toMatchObject([
895
+ {
896
+ 'core': {
897
+ 'type': 'path'
898
+ },
899
+ 'parameters': {
900
+ 'paths': [
901
+ '$PYENV_ROOT/bin',
902
+ '$BUN_INSTALL/bin',
903
+ '$DENO_INSTALL/bin',
904
+ '$JENV/bin',
905
+ '~/a/random/path',
906
+ '$NVM_DIR/.bin/2',
907
+ '$NVM_DIR/.bin/3'
908
+ ]
909
+ }
910
+ }
911
+ ])
912
+
913
+ const importResult2 = await controller.import({ type: 'path' }, { paths: ['$PYENV_ROOT/bin', '$BUN_INSTALL/bin'] });
914
+ expect(importResult2).toMatchObject([
915
+ {
916
+ 'core': {
917
+ 'type': 'path'
918
+ },
919
+ 'parameters': {
920
+ 'paths': [
921
+ '$PYENV_ROOT/bin',
922
+ '$BUN_INSTALL/bin',
923
+ '$DENO_INSTALL/bin',
924
+ '$JENV/bin',
925
+ '~/a/random/path',
926
+ '$NVM_DIR/.bin/2',
927
+ '$NVM_DIR/.bin/3'
928
+ ]
929
+ }
930
+ }
931
+ ])
932
+
933
+ process.env = oldProcessEnv;
832
934
  })
833
935
  });
@@ -438,7 +438,7 @@ export function resolveParameterTransformFn(
438
438
  from(input: unknown[], original) {
439
439
  return input.map((i, idx) => {
440
440
  const originalElement = Array.isArray(original)
441
- ? original.find((o) => resolveEqualsFn(parameter)(o, i)) ?? original[idx]
441
+ ? original.find((o) => resolveElementEqualsFn(parameter as ArrayParameterSetting)(o, i)) ?? original[idx]
442
442
  : original;
443
443
 
444
444
  return itemTransformation.from(i, originalElement);
@@ -41,11 +41,11 @@ describe('Utils tests', () => {
41
41
  expect(result2).to.eq('/var' + home + '/my/path');
42
42
  })
43
43
 
44
- it('Can add variables to a path', () => {
44
+ it('Can add variables to a path (ignores home)', () => {
45
45
  const testPath1 = os.homedir() + '/my/path';
46
46
  const result1 = addVariablesToPath(testPath1);
47
47
 
48
48
  const home = os.homedir();
49
- expect(result1).to.eq('$HOME/my/path');
49
+ expect(result1).to.eq(home + '/my/path');
50
50
  })
51
51
  })