codify-plugin-lib 1.0.182-beta24 → 1.0.182-beta26

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.
@@ -8,7 +8,7 @@ export function splitUserConfig(config) {
8
8
  ...(config.os ? { os: config.os } : {}),
9
9
  };
10
10
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
- const { type, name, dependsOn, ...parameters } = config;
11
+ const { type, name, dependsOn, os, ...parameters } = config;
12
12
  return {
13
13
  parameters: parameters,
14
14
  coreParameters,
@@ -20,6 +20,9 @@ export declare const Utils: {
20
20
  };
21
21
  isMacOS(): boolean;
22
22
  isLinux(): boolean;
23
+ isArmArch(): Promise<boolean>;
24
+ isHomebrewInstalled(): Promise<boolean>;
25
+ isRosetta2Installed(): Promise<boolean>;
23
26
  getShell(): Shell | undefined;
24
27
  getPrimaryShellRc(): string;
25
28
  getShellRcFiles(): string[];
@@ -1,6 +1,6 @@
1
1
  import os from 'node:os';
2
2
  import path from 'node:path';
3
- import { getPty } from '../pty/index.js';
3
+ import { getPty, SpawnStatus } from '../pty/index.js';
4
4
  export function isDebug() {
5
5
  return process.env.DEBUG != null && process.env.DEBUG.includes('codify'); // TODO: replace with debug library
6
6
  }
@@ -29,6 +29,29 @@ export const Utils = {
29
29
  isLinux() {
30
30
  return os.platform() === 'linux';
31
31
  },
32
+ async isArmArch() {
33
+ const $ = getPty();
34
+ if (!Utils.isMacOS()) {
35
+ // On Linux, check uname -m
36
+ const query = await $.spawn('uname -m');
37
+ return query.data.trim() === 'aarch64' || query.data.trim() === 'arm64';
38
+ }
39
+ const query = await $.spawn('sysctl -n machdep.cpu.brand_string');
40
+ return /M(\d)/.test(query.data);
41
+ },
42
+ async isHomebrewInstalled() {
43
+ const $ = getPty();
44
+ const query = await $.spawnSafe('which brew', { interactive: true });
45
+ return query.status === SpawnStatus.SUCCESS;
46
+ },
47
+ async isRosetta2Installed() {
48
+ if (!Utils.isMacOS()) {
49
+ return false;
50
+ }
51
+ const $ = getPty();
52
+ const query = await $.spawnSafe('arch -x86_64 /usr/bin/true 2> /dev/null', { interactive: true });
53
+ return query.status === SpawnStatus.SUCCESS;
54
+ },
32
55
  getShell() {
33
56
  const shell = process.env.SHELL || '';
34
57
  if (shell.endsWith('bash')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.182-beta24",
3
+ "version": "1.0.182-beta26",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,7 +13,7 @@ export function splitUserConfig<T extends StringIndexedObject>(
13
13
  };
14
14
 
15
15
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- const { type, name, dependsOn, ...parameters } = config;
16
+ const { type, name, dependsOn, os, ...parameters } = config;
17
17
 
18
18
  return {
19
19
  parameters: parameters as T,
@@ -1,7 +1,7 @@
1
1
  import { OS } from 'codify-schemas';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
- import { getPty } from '../pty/index.js';
4
+ import { getPty, SpawnStatus } from '../pty/index.js';
5
5
 
6
6
  export function isDebug(): boolean {
7
7
  return process.env.DEBUG != null && process.env.DEBUG.includes('codify'); // TODO: replace with debug library
@@ -41,6 +41,34 @@ export const Utils = {
41
41
  return os.platform() === 'linux';
42
42
  },
43
43
 
44
+ async isArmArch(): Promise<boolean> {
45
+ const $ = getPty();
46
+ if (!Utils.isMacOS()) {
47
+ // On Linux, check uname -m
48
+ const query = await $.spawn('uname -m');
49
+ return query.data.trim() === 'aarch64' || query.data.trim() === 'arm64';
50
+ }
51
+
52
+ const query = await $.spawn('sysctl -n machdep.cpu.brand_string');
53
+ return /M(\d)/.test(query.data);
54
+ },
55
+
56
+ async isHomebrewInstalled(): Promise<boolean> {
57
+ const $ = getPty();
58
+ const query = await $.spawnSafe('which brew', { interactive: true });
59
+ return query.status === SpawnStatus.SUCCESS;
60
+ },
61
+
62
+ async isRosetta2Installed(): Promise<boolean> {
63
+ if (!Utils.isMacOS()) {
64
+ return false;
65
+ }
66
+
67
+ const $ = getPty();
68
+ const query = await $.spawnSafe('arch -x86_64 /usr/bin/true 2> /dev/null', { interactive: true });
69
+ return query.status === SpawnStatus.SUCCESS;
70
+ },
71
+
44
72
  getShell(): Shell | undefined {
45
73
  const shell = process.env.SHELL || '';
46
74