piral-cli 1.3.1 → 1.3.2-beta.6173

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.
@@ -0,0 +1,7 @@
1
+ export declare function installDependencies(target?: string, ...flags: Array<string>): Promise<string>;
2
+ export declare function uninstallPackage(packageRef: string, target?: string, ...flags: Array<string>): Promise<string>;
3
+ export declare function installPackage(packageRef: string, target?: string, ...flags: Array<string>): Promise<string>;
4
+ export declare function detectClient(root: string, stopDir?: string): Promise<boolean>;
5
+ export declare function initProject(projectName: string, target: string): Promise<void>;
6
+ export declare function isProject(root: string, packageRef: string): Promise<boolean>;
7
+ export declare function listProjects(target: string): Promise<{}>;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.listProjects = exports.isProject = exports.initProject = exports.detectClient = exports.installPackage = exports.uninstallPackage = exports.installDependencies = void 0;
13
+ const path_1 = require("path");
14
+ const log_1 = require("../log");
15
+ const io_1 = require("../io");
16
+ const scripts_1 = require("../scripts");
17
+ const MemoryStream_1 = require("../MemoryStream");
18
+ // Helpers:
19
+ function runBunProcess(args, target, output) {
20
+ (0, log_1.log)('generalDebug_0003', 'Starting the Bun process ...');
21
+ const cwd = (0, path_1.resolve)(process.cwd(), target);
22
+ return (0, scripts_1.runCommand)('bun', args, cwd, output);
23
+ }
24
+ function convert(flags) {
25
+ return flags.map((flag) => {
26
+ switch (flag) {
27
+ case '--save-exact':
28
+ return '--exact';
29
+ case '--save-dev':
30
+ return '--dev';
31
+ case '--no-save':
32
+ // unfortunately no (https://github.com/yarnpkg/yarn/issues/1743)
33
+ return '';
34
+ default:
35
+ return flag;
36
+ }
37
+ });
38
+ }
39
+ // Client interface functions:
40
+ function installDependencies(target = '.', ...flags) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const ms = new MemoryStream_1.MemoryStream();
43
+ yield runBunProcess(['install', ...convert(flags)], target, ms);
44
+ (0, log_1.log)('generalDebug_0003', `Bun install dependencies result: ${ms.value}`);
45
+ return ms.value;
46
+ });
47
+ }
48
+ exports.installDependencies = installDependencies;
49
+ function uninstallPackage(packageRef, target = '.', ...flags) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const ms = new MemoryStream_1.MemoryStream();
52
+ yield runBunProcess(['remove', packageRef, ...convert(flags)], target, ms);
53
+ (0, log_1.log)('generalDebug_0003', `Bun remove package result: ${ms.value}`);
54
+ return ms.value;
55
+ });
56
+ }
57
+ exports.uninstallPackage = uninstallPackage;
58
+ function installPackage(packageRef, target = '.', ...flags) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const ms = new MemoryStream_1.MemoryStream();
61
+ yield runBunProcess(['add', packageRef, ...convert(flags)], target, ms);
62
+ (0, log_1.log)('generalDebug_0003', `Bun add package result: ${ms.value}`);
63
+ return ms.value;
64
+ });
65
+ }
66
+ exports.installPackage = installPackage;
67
+ function detectClient(root, stopDir = (0, path_1.resolve)(root, '/')) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ return !!(yield (0, io_1.findFile)(root, 'bun.lockb', stopDir));
70
+ });
71
+ }
72
+ exports.detectClient = detectClient;
73
+ function initProject(projectName, target) {
74
+ return __awaiter(this, void 0, void 0, function* () { });
75
+ }
76
+ exports.initProject = initProject;
77
+ function isProject(root, packageRef) {
78
+ var _a;
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const details = yield listProjects(root);
81
+ if (typeof details === 'object') {
82
+ // TODO this won't work right now
83
+ return typeof ((_a = details === null || details === void 0 ? void 0 : details[packageRef]) === null || _a === void 0 ? void 0 : _a.location) === 'string';
84
+ }
85
+ return false;
86
+ });
87
+ }
88
+ exports.isProject = isProject;
89
+ // Functions to exclusively use from yarn client:
90
+ function listProjects(target) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ const ms = new MemoryStream_1.MemoryStream();
93
+ try {
94
+ yield runBunProcess(['pm', 'ls', '--all'], target, ms);
95
+ }
96
+ catch (e) {
97
+ (0, log_1.log)('generalDebug_0003', `Bun workspaces error: ${e}`);
98
+ return {};
99
+ }
100
+ (0, log_1.log)('generalDebug_0003', `Bun workspaces result: ${ms.value}`);
101
+ return ms.value.split('\n').filter(m => m.startsWith('├──')).map(m => m.replace('├── ', ''));
102
+ });
103
+ }
104
+ exports.listProjects = listProjects;
105
+ //# sourceMappingURL=bun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bun.js","sourceRoot":"","sources":["../../../src/common/clients/bun.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,gCAA6B;AAC7B,8BAAiC;AACjC,wCAAwC;AACxC,kDAA+C;AAE/C,WAAW;AAEX,SAAS,aAAa,CAAC,IAAmB,EAAE,MAAc,EAAE,MAA8B;IACxF,IAAA,SAAG,EAAC,mBAAmB,EAAE,8BAA8B,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO,IAAA,oBAAU,EAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,OAAO,CAAC,KAAoB;IACnC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,QAAQ,IAAI,EAAE;YACZ,KAAK,cAAc;gBACjB,OAAO,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EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/F,CAAC;CAAA;AAZD,oCAYC"}
@@ -4,6 +4,7 @@ import * as pnp from './pnp';
4
4
  import * as pnpm from './pnpm';
5
5
  import * as rush from './rush';
6
6
  import * as yarn from './yarn';
7
+ import * as bun from './bun';
7
8
  export declare const clients: {
8
9
  lerna: typeof lerna;
9
10
  npm: typeof npm;
@@ -11,11 +12,12 @@ export declare const clients: {
11
12
  pnpm: typeof pnpm;
12
13
  rush: typeof rush;
13
14
  yarn: typeof yarn;
15
+ bun: typeof bun;
14
16
  };
15
17
  type ClientName = keyof typeof clients;
16
18
  export declare function isWrapperClient(client: ClientName): boolean;
17
19
  export declare function detectClients(root: string): Promise<{
18
- client: "npm" | "yarn" | "pnp" | "pnpm" | "lerna" | "rush";
20
+ client: "npm" | "yarn" | "pnp" | "pnpm" | "lerna" | "rush" | "bun";
19
21
  result: boolean;
20
22
  }[]>;
21
23
  export {};
@@ -18,6 +18,7 @@ const pnp = require("./pnp");
18
18
  const pnpm = require("./pnpm");
19
19
  const rush = require("./rush");
20
20
  const yarn = require("./yarn");
21
+ const bun = require("./bun");
21
22
  exports.clients = {
22
23
  lerna,
23
24
  npm,
@@ -25,8 +26,9 @@ exports.clients = {
25
26
  pnpm,
26
27
  rush,
27
28
  yarn,
29
+ bun,
28
30
  };
29
- const directClients = ['npm', 'pnp', 'yarn', 'pnpm'];
31
+ const directClients = ['npm', 'pnp', 'yarn', 'pnpm', 'bun'];
30
32
  function isWrapperClient(client) {
31
33
  return !directClients.includes(client);
32
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/clients/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAwC;AACxC,8BAAiC;AAEjC,iCAAiC;AACjC,6BAA6B;AAC7B,6BAA6B;AAC7B,+BAA+B;AAC/B,+BAA+B;AAC/B,+BAA+B;AAElB,QAAA,OAAO,GAAG;IACrB,KAAK;IACL,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC;AAIF,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,SAAgB,eAAe,CAAC,MAAkB;IAChD,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC;AAFD,0CAEC;AAED,SAAsB,aAAa,CAAC,IAAY;;QAC9C,MAAM,WAAW,GAAG,MAAM,IAAA,aAAQ,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;QACxE,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE/D,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,MAAM,CAAC,IAAI,CAAC,eAAO,CAAC,CAAC,GAAG,CAAC,CAAO,MAAkB,EAAE,EAAE;YACpD,MAAM,MAAM,GAAG,MAAM,eAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACjE,OAAO;gBACL,MAAM;gBACN,MAAM;aACP,CAAC;QACJ,CAAC,CAAA,CAAC,CACH,CAAC;IACJ,CAAC;CAAA;AAbD,sCAaC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/clients/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAwC;AACxC,8BAAiC;AAEjC,iCAAiC;AACjC,6BAA6B;AAC7B,6BAA6B;AAC7B,+BAA+B;AAC/B,+BAA+B;AAC/B,+BAA+B;AAC/B,6BAA6B;AAEhB,QAAA,OAAO,GAAG;IACrB,KAAK;IACL,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;CACJ,CAAC;AAIF,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAE5D,SAAgB,eAAe,CAAC,MAAkB;IAChD,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC;AAFD,0CAEC;AAED,SAAsB,aAAa,CAAC,IAAY;;QAC9C,MAAM,WAAW,GAAG,MAAM,IAAA,aAAQ,EAAC,IAAA,cAAO,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;QACxE,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE/D,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,MAAM,CAAC,IAAI,CAAC,eAAO,CAAC,CAAC,GAAG,CAAC,CAAO,MAAkB,EAAE,EAAE;YACpD,MAAM,MAAM,GAAG,MAAM,eAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACjE,OAAO;gBACL,MAAM;gBACN,MAAM;aACP,CAAC;QACJ,CAAC,CAAA,CAAC,CACH,CAAC;IACJ,CAAC;CAAA;AAbD,sCAaC"}
@@ -10,6 +10,6 @@ export declare const frameworkLibs: ("piral" | "piral-core" | "piral-base")[];
10
10
  export declare const piletJsonSchemaUrl = "https://docs.piral.io/schemas/pilet-v0.json";
11
11
  export declare const piralJsonSchemaUrl = "https://docs.piral.io/schemas/piral-v0.json";
12
12
  export declare const entryModuleExtensions: string[];
13
- export declare const bundlerNames: ("webpack" | "esbuild" | "parcel" | "parcel2" | "rollup" | "rspack" | "webpack5" | "vite" | "xbuild")[];
13
+ export declare const bundlerNames: ("bun" | "webpack" | "esbuild" | "parcel" | "parcel2" | "rollup" | "rspack" | "webpack5" | "vite" | "xbuild")[];
14
14
  export declare const declarationEntryExtensions: string[];
15
15
  export declare const legacyCoreExternals: string[];
@@ -14,6 +14,7 @@ exports.piletJsonSchemaUrl = 'https://docs.piral.io/schemas/pilet-v0.json';
14
14
  exports.piralJsonSchemaUrl = 'https://docs.piral.io/schemas/piral-v0.json';
15
15
  exports.entryModuleExtensions = ['.ts', '.tsx', '.js', '.jsx'];
16
16
  exports.bundlerNames = [
17
+ 'bun',
17
18
  'esbuild',
18
19
  'parcel',
19
20
  'parcel2',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,6BAA6B,CAAC;AAChD,QAAA,QAAQ,GAAG,OAAO,CAAC;AACnB,QAAA,WAAW,GAAG,cAAc,CAAC;AAC7B,QAAA,SAAS,GAAG,YAAY,CAAC;AACzB,QAAA,SAAS,GAAG,YAAY,CAAC;AACzB,QAAA,YAAY,GAAG,YAAY,CAAC;AAC5B,QAAA,aAAa,GAAG,yBAAyB,CAAC;AAC1C,QAAA,oBAAoB,GAAG,IAAI,CAAC;AAC5B,QAAA,aAAa,GAAG,CAAC,OAAgB,EAAE,YAAqB,EAAE,YAAqB,CAAC,CAAC;AACjF,QAAA,kBAAkB,GAAG,6CAA6C,CAAC;AACnE,QAAA,kBAAkB,GAAG,6CAA6C,CAAC;AACnE,QAAA,qBAAqB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACvD,QAAA,YAAY,GAAG;IAC1B,SAAkB;IAClB,QAAiB;IACjB,SAAkB;IAClB,QAAiB;IACjB,QAAiB;IACjB,SAAkB;IAClB,UAAmB;IACnB,MAAe;IACf,QAAiB;CAClB,CAAC;AACW,QAAA,0BAA0B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,6BAAqB,CAAC,CAAC;AACzE,QAAA,mBAAmB,GAAG;IACjC,sBAAsB;IACtB,aAAa;IACb,SAAS;IACT,OAAO;IACP,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,OAAO;IACP,gBAAgB;CACjB,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,6BAA6B,CAAC;AAChD,QAAA,QAAQ,GAAG,OAAO,CAAC;AACnB,QAAA,WAAW,GAAG,cAAc,CAAC;AAC7B,QAAA,SAAS,GAAG,YAAY,CAAC;AACzB,QAAA,SAAS,GAAG,YAAY,CAAC;AACzB,QAAA,YAAY,GAAG,YAAY,CAAC;AAC5B,QAAA,aAAa,GAAG,yBAAyB,CAAC;AAC1C,QAAA,oBAAoB,GAAG,IAAI,CAAC;AAC5B,QAAA,aAAa,GAAG,CAAC,OAAgB,EAAE,YAAqB,EAAE,YAAqB,CAAC,CAAC;AACjF,QAAA,kBAAkB,GAAG,6CAA6C,CAAC;AACnE,QAAA,kBAAkB,GAAG,6CAA6C,CAAC;AACnE,QAAA,qBAAqB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACvD,QAAA,YAAY,GAAG;IAC1B,KAAc;IACd,SAAkB;IAClB,QAAiB;IACjB,SAAkB;IAClB,QAAiB;IACjB,QAAiB;IACjB,SAAkB;IAClB,UAAmB;IACnB,MAAe;IACf,QAAiB;CAClB,CAAC;AACW,QAAA,0BAA0B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,6BAAqB,CAAC,CAAC;AACzE,QAAA,mBAAmB,GAAG;IACjC,sBAAsB;IACtB,aAAa;IACb,SAAS;IACT,OAAO;IACP,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,OAAO;IACP,gBAAgB;CACjB,CAAC"}
@@ -200,7 +200,7 @@ export type PiletPublishSource = 'local' | 'npm' | 'remote';
200
200
  export type PiralBuildType = 'all' | 'release' | 'emulator' | 'emulator-sources';
201
201
  export type PiletBuildType = 'default' | 'standalone' | 'manifest';
202
202
  export type PackageType = 'registry' | 'file' | 'git';
203
- export type NpmClientType = 'npm' | 'yarn' | 'pnp' | 'pnpm' | 'lerna' | 'rush';
203
+ export type NpmClientType = 'npm' | 'yarn' | 'pnp' | 'pnpm' | 'lerna' | 'rush' | 'bun';
204
204
  export type Framework = 'piral' | 'piral-core' | 'piral-base';
205
205
  export interface StandardEnvProps {
206
206
  production?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cli",
3
- "version": "1.3.1",
3
+ "version": "1.3.2-beta.6173",
4
4
  "description": "The standard CLI for creating and building a Piral instance or a Pilet.",
5
5
  "keywords": [
6
6
  "portal",
@@ -81,5 +81,5 @@
81
81
  "typescript": "^5.0.0",
82
82
  "yargs": "^15.0.0"
83
83
  },
84
- "gitHead": "b8d5d565ebfffc3aa4b60db561da885965aa3dd9"
84
+ "gitHead": "f9f5a133060e400174c7719c1d20831aca36c858"
85
85
  }
@@ -0,0 +1,85 @@
1
+ import { resolve } from 'path';
2
+ import { log } from '../log';
3
+ import { findFile } from '../io';
4
+ import { runCommand } from '../scripts';
5
+ import { MemoryStream } from '../MemoryStream';
6
+
7
+ // Helpers:
8
+
9
+ function runBunProcess(args: Array<string>, target: string, output?: NodeJS.WritableStream) {
10
+ log('generalDebug_0003', 'Starting the Bun process ...');
11
+ const cwd = resolve(process.cwd(), target);
12
+ return runCommand('bun', args, cwd, output);
13
+ }
14
+
15
+ function convert(flags: Array<string>) {
16
+ return flags.map((flag) => {
17
+ switch (flag) {
18
+ case '--save-exact':
19
+ return '--exact';
20
+ case '--save-dev':
21
+ return '--dev';
22
+ case '--no-save':
23
+ // unfortunately no (https://github.com/yarnpkg/yarn/issues/1743)
24
+ return '';
25
+ default:
26
+ return flag;
27
+ }
28
+ });
29
+ }
30
+
31
+ // Client interface functions:
32
+
33
+ export async function installDependencies(target = '.', ...flags: Array<string>) {
34
+ const ms = new MemoryStream();
35
+ await runBunProcess(['install', ...convert(flags)], target, ms);
36
+ log('generalDebug_0003', `Bun install dependencies result: ${ms.value}`);
37
+ return ms.value;
38
+ }
39
+
40
+ export async function uninstallPackage(packageRef: string, target = '.', ...flags: Array<string>) {
41
+ const ms = new MemoryStream();
42
+ await runBunProcess(['remove', packageRef, ...convert(flags)], target, ms);
43
+ log('generalDebug_0003', `Bun remove package result: ${ms.value}`);
44
+ return ms.value;
45
+ }
46
+
47
+ export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
48
+ const ms = new MemoryStream();
49
+ await runBunProcess(['add', packageRef, ...convert(flags)], target, ms);
50
+ log('generalDebug_0003', `Bun add package result: ${ms.value}`);
51
+ return ms.value;
52
+ }
53
+
54
+ export async function detectClient(root: string, stopDir = resolve(root, '/')) {
55
+ return !!(await findFile(root, 'bun.lockb', stopDir));
56
+ }
57
+
58
+ export async function initProject(projectName: string, target: string) {}
59
+
60
+ export async function isProject(root: string, packageRef: string) {
61
+ const details = await listProjects(root);
62
+
63
+ if (typeof details === 'object') {
64
+ // TODO this won't work right now
65
+ return typeof details?.[packageRef]?.location === 'string';
66
+ }
67
+
68
+ return false;
69
+ }
70
+
71
+ // Functions to exclusively use from yarn client:
72
+
73
+ export async function listProjects(target: string) {
74
+ const ms = new MemoryStream();
75
+
76
+ try {
77
+ await runBunProcess(['pm', 'ls', '--all'], target, ms);
78
+ } catch (e) {
79
+ log('generalDebug_0003', `Bun workspaces error: ${e}`);
80
+ return {};
81
+ }
82
+
83
+ log('generalDebug_0003', `Bun workspaces result: ${ms.value}`);
84
+ return ms.value.split('\n').filter(m => m.startsWith('├──')).map(m => m.replace('├── ', ''));
85
+ }
@@ -7,6 +7,7 @@ import * as pnp from './pnp';
7
7
  import * as pnpm from './pnpm';
8
8
  import * as rush from './rush';
9
9
  import * as yarn from './yarn';
10
+ import * as bun from './bun';
10
11
 
11
12
  export const clients = {
12
13
  lerna,
@@ -15,11 +16,12 @@ export const clients = {
15
16
  pnpm,
16
17
  rush,
17
18
  yarn,
19
+ bun,
18
20
  };
19
21
 
20
22
  type ClientName = keyof typeof clients;
21
23
 
22
- const directClients = ['npm', 'pnp', 'yarn', 'pnpm'];
24
+ const directClients = ['npm', 'pnp', 'yarn', 'pnpm', 'bun'];
23
25
 
24
26
  export function isWrapperClient(client: ClientName) {
25
27
  return !directClients.includes(client);
@@ -11,6 +11,7 @@ export const piletJsonSchemaUrl = 'https://docs.piral.io/schemas/pilet-v0.json';
11
11
  export const piralJsonSchemaUrl = 'https://docs.piral.io/schemas/piral-v0.json';
12
12
  export const entryModuleExtensions = ['.ts', '.tsx', '.js', '.jsx'];
13
13
  export const bundlerNames = [
14
+ 'bun' as const,
14
15
  'esbuild' as const,
15
16
  'parcel' as const,
16
17
  'parcel2' as const,
@@ -237,7 +237,7 @@ export type PiletBuildType = 'default' | 'standalone' | 'manifest';
237
237
 
238
238
  export type PackageType = 'registry' | 'file' | 'git';
239
239
 
240
- export type NpmClientType = 'npm' | 'yarn' | 'pnp' | 'pnpm' | 'lerna' | 'rush';
240
+ export type NpmClientType = 'npm' | 'yarn' | 'pnp' | 'pnpm' | 'lerna' | 'rush' | 'bun';
241
241
 
242
242
  export type Framework = 'piral' | 'piral-core' | 'piral-base';
243
243