codify-plugin-lib 1.0.182-beta65 → 1.0.182-beta67

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/dist/plan/plan.js CHANGED
@@ -197,7 +197,9 @@ export class Plan {
197
197
  }
198
198
  // For stateful mode, we're done after filtering by the keys of desired + state. Stateless mode
199
199
  // requires additional filtering for stateful parameter arrays and objects.
200
- if (isStateful) {
200
+ // We also want to filter parameters when in delete mode. We don't want to delete parameters that
201
+ // are not specified in the original config.
202
+ if (isStateful && desired !== null) {
201
203
  return filteredCurrent;
202
204
  }
203
205
  // TODO: Add object handling here in addition to arrays in the future
@@ -42,5 +42,5 @@ export declare const Utils: {
42
42
  isFedora(): Promise<boolean>;
43
43
  isRHEL(): Promise<boolean>;
44
44
  isDebianBased(): boolean;
45
- isRPMBased(): boolean;
45
+ isRedhatBased(): boolean;
46
46
  };
@@ -1,9 +1,9 @@
1
1
  import { LinuxDistro } from 'codify-schemas';
2
+ import * as fsSync from 'node:fs';
2
3
  import * as fs from 'node:fs/promises';
3
4
  import os from 'node:os';
4
5
  import path from 'node:path';
5
6
  import { SpawnStatus, getPty } from '../pty/index.js';
6
- import * as fsSync from 'node:fs';
7
7
  export function isDebug() {
8
8
  return process.env.DEBUG != null && process.env.DEBUG.includes('codify'); // TODO: replace with debug library
9
9
  }
@@ -167,10 +167,16 @@ Brew can be installed using Codify:
167
167
  const isAptInstalled = await $.spawnSafe('which apt');
168
168
  if (isAptInstalled.status === SpawnStatus.SUCCESS) {
169
169
  await $.spawn('apt-get update', { requiresRoot: true });
170
- const { status, data } = await $.spawnSafe(`apt-get -y install ${packageName}`, { requiresRoot: true, env: { DEBIAN_FRONTEND: 'noninteractive' } });
170
+ const { status, data } = await $.spawnSafe(`apt-get -y install ${packageName}`, {
171
+ requiresRoot: true,
172
+ env: { DEBIAN_FRONTEND: 'noninteractive' }
173
+ });
171
174
  if (status === SpawnStatus.ERROR && data.includes('E: dpkg was interrupted, you must manually run \'sudo dpkg --configure -a\' to correct the problem.')) {
172
175
  await $.spawn('dpkg --configure -a', { requiresRoot: true });
173
- await $.spawn(`apt-get -y install ${packageName}`, { requiresRoot: true, env: { DEBIAN_FRONTEND: 'noninteractive' } });
176
+ await $.spawn(`apt-get -y install ${packageName}`, {
177
+ requiresRoot: true,
178
+ env: { DEBIAN_FRONTEND: 'noninteractive' }
179
+ });
174
180
  return;
175
181
  }
176
182
  if (status === SpawnStatus.ERROR) {
@@ -198,13 +204,19 @@ Brew can be installed using Codify:
198
204
  const $ = getPty();
199
205
  if (Utils.isMacOS()) {
200
206
  await this.assertBrewInstalled();
201
- const { status } = await $.spawnSafe(`brew uninstall --zap ${packageName}`, { interactive: true, env: { HOMEBREW_NO_AUTO_UPDATE: 1 } });
207
+ const { status } = await $.spawnSafe(`brew uninstall --zap ${packageName}`, {
208
+ interactive: true,
209
+ env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
210
+ });
202
211
  return status === SpawnStatus.SUCCESS;
203
212
  }
204
213
  if (Utils.isLinux()) {
205
214
  const isAptInstalled = await $.spawnSafe('which apt');
206
215
  if (isAptInstalled.status === SpawnStatus.SUCCESS) {
207
- const { status } = await $.spawnSafe(`apt-get autoremove -y --purge ${packageName}`, { requiresRoot: true, env: { DEBIAN_FRONTEND: 'noninteractive' } });
216
+ const { status } = await $.spawnSafe(`apt-get autoremove -y --purge ${packageName}`, {
217
+ requiresRoot: true,
218
+ env: { DEBIAN_FRONTEND: 'noninteractive' }
219
+ });
208
220
  return status === SpawnStatus.SUCCESS;
209
221
  }
210
222
  const isDnfInstalled = await $.spawnSafe('which dnf');
@@ -226,7 +238,7 @@ Brew can be installed using Codify:
226
238
  const lines = osRelease.split('\n');
227
239
  for (const line of lines) {
228
240
  if (line.startsWith('ID=')) {
229
- const distroId = line.slice(3).trim().replace(/"/g, '');
241
+ const distroId = line.slice(3).trim().replaceAll('"', '');
230
242
  return Object.values(LinuxDistro).includes(distroId) ? distroId : undefined;
231
243
  }
232
244
  }
@@ -253,7 +265,7 @@ Brew can be installed using Codify:
253
265
  isDebianBased() {
254
266
  return fsSync.existsSync('/etc/debian_version');
255
267
  },
256
- isRPMBased() {
268
+ isRedhatBased() {
257
269
  return fsSync.existsSync('/etc/redhat-release');
258
270
  }
259
271
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.182-beta65",
3
+ "version": "1.0.182-beta67",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
package/src/plan/plan.ts CHANGED
@@ -326,7 +326,9 @@ export class Plan<T extends StringIndexedObject> {
326
326
 
327
327
  // For stateful mode, we're done after filtering by the keys of desired + state. Stateless mode
328
328
  // requires additional filtering for stateful parameter arrays and objects.
329
- if (isStateful) {
329
+ // We also want to filter parameters when in delete mode. We don't want to delete parameters that
330
+ // are not specified in the original config.
331
+ if (isStateful && desired !== null) {
330
332
  return filteredCurrent;
331
333
  }
332
334
 
@@ -1,10 +1,10 @@
1
1
  import { LinuxDistro, OS } from 'codify-schemas';
2
+ import * as fsSync from 'node:fs';
2
3
  import * as fs from 'node:fs/promises';
3
4
  import os from 'node:os';
4
5
  import path from 'node:path';
5
6
 
6
7
  import { SpawnStatus, getPty } from '../pty/index.js';
7
- import * as fsSync from 'node:fs';
8
8
 
9
9
  export function isDebug(): boolean {
10
10
  return process.env.DEBUG != null && process.env.DEBUG.includes('codify'); // TODO: replace with debug library
@@ -209,11 +209,17 @@ Brew can be installed using Codify:
209
209
  const isAptInstalled = await $.spawnSafe('which apt');
210
210
  if (isAptInstalled.status === SpawnStatus.SUCCESS) {
211
211
  await $.spawn('apt-get update', { requiresRoot: true });
212
- const { status, data } = await $.spawnSafe(`apt-get -y install ${packageName}`, { requiresRoot: true, env: { DEBIAN_FRONTEND: 'noninteractive' } });
212
+ const { status, data } = await $.spawnSafe(`apt-get -y install ${packageName}`, {
213
+ requiresRoot: true,
214
+ env: { DEBIAN_FRONTEND: 'noninteractive' }
215
+ });
213
216
 
214
217
  if (status === SpawnStatus.ERROR && data.includes('E: dpkg was interrupted, you must manually run \'sudo dpkg --configure -a\' to correct the problem.')) {
215
218
  await $.spawn('dpkg --configure -a', { requiresRoot: true });
216
- await $.spawn(`apt-get -y install ${packageName}`, { requiresRoot: true, env: { DEBIAN_FRONTEND: 'noninteractive' } });
219
+ await $.spawn(`apt-get -y install ${packageName}`, {
220
+ requiresRoot: true,
221
+ env: { DEBIAN_FRONTEND: 'noninteractive' }
222
+ });
217
223
 
218
224
  return;
219
225
  }
@@ -249,14 +255,20 @@ Brew can be installed using Codify:
249
255
 
250
256
  if (Utils.isMacOS()) {
251
257
  await this.assertBrewInstalled();
252
- const { status } = await $.spawnSafe(`brew uninstall --zap ${packageName}`, { interactive: true, env: { HOMEBREW_NO_AUTO_UPDATE: 1 } });
258
+ const { status } = await $.spawnSafe(`brew uninstall --zap ${packageName}`, {
259
+ interactive: true,
260
+ env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
261
+ });
253
262
  return status === SpawnStatus.SUCCESS;
254
263
  }
255
264
 
256
265
  if (Utils.isLinux()) {
257
266
  const isAptInstalled = await $.spawnSafe('which apt');
258
267
  if (isAptInstalled.status === SpawnStatus.SUCCESS) {
259
- const { status } = await $.spawnSafe(`apt-get autoremove -y --purge ${packageName}`, { requiresRoot: true, env: { DEBIAN_FRONTEND: 'noninteractive' } });
268
+ const { status } = await $.spawnSafe(`apt-get autoremove -y --purge ${packageName}`, {
269
+ requiresRoot: true,
270
+ env: { DEBIAN_FRONTEND: 'noninteractive' }
271
+ });
260
272
  return status === SpawnStatus.SUCCESS;
261
273
  }
262
274
 
@@ -283,11 +295,11 @@ Brew can be installed using Codify:
283
295
  const lines = osRelease.split('\n');
284
296
  for (const line of lines) {
285
297
  if (line.startsWith('ID=')) {
286
- const distroId = line.slice(3).trim().replace(/"/g, '');
298
+ const distroId = line.slice(3).trim().replaceAll('"', '');
287
299
  return Object.values(LinuxDistro).includes(distroId as LinuxDistro) ? distroId as LinuxDistro : undefined;
288
300
  }
289
301
  }
290
-
302
+
291
303
  return undefined;
292
304
  },
293
305
 
@@ -319,7 +331,7 @@ Brew can be installed using Codify:
319
331
  return fsSync.existsSync('/etc/debian_version');
320
332
  },
321
333
 
322
- isRPMBased(): boolean {
334
+ isRedhatBased(): boolean {
323
335
  return fsSync.existsSync('/etc/redhat-release');
324
336
  }
325
337
  };