balena-cli 25.0.0 → 25.1.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
4
4
  automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
5
5
  This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## 25.1.0 - 2026-04-28
8
+
9
+ * Add organization management commands [Thodoris Greasidis]
10
+
7
11
  ## 25.0.0 - 2026-04-28
8
12
 
9
13
  * Update @balena/compose to v8, add @balena/compose-parser dependency [Christina Ying Wang]
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class OrganizationCreateCmd extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ orgName: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static authenticated: boolean;
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const lazy_1 = require("../../utils/lazy");
5
+ class OrganizationCreateCmd extends core_1.Command {
6
+ async run() {
7
+ const { args: params } = await this.parse(OrganizationCreateCmd);
8
+ const balena = (0, lazy_1.getBalenaSdk)();
9
+ const org = await balena.models.organization.create({
10
+ name: params.orgName,
11
+ });
12
+ console.log((0, lazy_1.getVisuals)().table.vertical(org, ['id', 'name', 'handle', 'created_at']));
13
+ }
14
+ }
15
+ OrganizationCreateCmd.description = (0, lazy_1.stripIndent) `
16
+ Create an organization.
17
+
18
+ Create a new organization.
19
+ `;
20
+ OrganizationCreateCmd.examples = ['$ balena organization create MyOrg'];
21
+ OrganizationCreateCmd.args = {
22
+ orgName: core_1.Args.string({
23
+ description: 'the name to use for the new organization',
24
+ required: true,
25
+ }),
26
+ };
27
+ OrganizationCreateCmd.authenticated = true;
28
+ exports.default = OrganizationCreateCmd;
29
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/organization/create.ts"],"names":[],"mappings":";;AAiBA,sCAA4C;AAC5C,2CAAyE;AAEzE,MAAqB,qBAAsB,SAAQ,cAAO;IAkBlD,KAAK,CAAC,GAAG;QACf,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAEjE,MAAM,MAAM,GAAG,IAAA,mBAAY,GAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC;YACnD,IAAI,EAAE,MAAM,CAAC,OAAO;SACpB,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CACV,IAAA,iBAAU,GAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CACxE,CAAC;IACH,CAAC;;AA5Ba,iCAAW,GAAG,IAAA,kBAAW,EAAA;;;;CAIvC,CAAC;AAEa,8BAAQ,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAElD,0BAAI,GAAG;IACpB,OAAO,EAAE,WAAI,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,0CAA0C;QACvD,QAAQ,EAAE,IAAI;KACd,CAAC;CACF,CAAC;AAEY,mCAAa,GAAG,IAAI,CAAC;kBAhBf,qBAAqB"}
@@ -0,0 +1,11 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class OrganizationRenameCmd extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ handle: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ newName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
8
+ };
9
+ static authenticated: boolean;
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const lazy_1 = require("../../utils/lazy");
5
+ class OrganizationRenameCmd extends core_1.Command {
6
+ async run() {
7
+ const { args: params } = await this.parse(OrganizationRenameCmd);
8
+ const balena = (0, lazy_1.getBalenaSdk)();
9
+ const newName = params.newName ||
10
+ (await (0, lazy_1.getCliForm)().ask({
11
+ message: 'How do you want to name this organization?',
12
+ type: 'input',
13
+ })) ||
14
+ '';
15
+ const org = await balena.models.organization.get(params.handle, {
16
+ $select: 'id',
17
+ });
18
+ await balena.pine.patch({
19
+ resource: 'organization',
20
+ id: org.id,
21
+ body: {
22
+ name: newName,
23
+ },
24
+ });
25
+ }
26
+ }
27
+ OrganizationRenameCmd.description = (0, lazy_1.stripIndent) `
28
+ Rename an organization.
29
+
30
+ Rename an organization.
31
+
32
+ Note, if the name is omitted, it will be prompted for interactively.
33
+ `;
34
+ OrganizationRenameCmd.examples = [
35
+ '$ balena organization rename my_org_handle',
36
+ '$ balena organization rename my_org_handle "My New Org"',
37
+ ];
38
+ OrganizationRenameCmd.args = {
39
+ handle: core_1.Args.string({
40
+ description: 'the handle of the organization to rename',
41
+ required: true,
42
+ }),
43
+ newName: core_1.Args.string({
44
+ description: 'the new name for the organization',
45
+ }),
46
+ };
47
+ OrganizationRenameCmd.authenticated = true;
48
+ exports.default = OrganizationRenameCmd;
49
+ //# sourceMappingURL=rename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename.js","sourceRoot":"","sources":["../../../src/commands/organization/rename.ts"],"names":[],"mappings":";;AAiBA,sCAA4C;AAC5C,2CAAyE;AAEzE,MAAqB,qBAAsB,SAAQ,cAAO;IAyBlD,KAAK,CAAC,GAAG;QACf,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAEjE,MAAM,MAAM,GAAG,IAAA,mBAAY,GAAE,CAAC;QAE9B,MAAM,OAAO,GAEZ,MAAM,CAAC,OAAO;YACd,CAAC,MAAM,IAAA,iBAAU,GAAE,CAAC,GAAG,CAAC;gBACvB,OAAO,EAAE,4CAA4C;gBACrD,IAAI,EAAE,OAAO;aAEb,CAAC,CAAC;YACH,EAAE,CAAC;QAEJ,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;YAC/D,OAAO,EAAE,IAAI;SACb,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YACvB,QAAQ,EAAE,cAAc;YACxB,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,IAAI,EAAE;gBACL,IAAI,EAAE,OAAO;aACb;SACD,CAAC,CAAC;IACJ,CAAC;;AAjDa,iCAAW,GAAG,IAAA,kBAAW,EAAA;;;;;;GAMrC,CAAC;AACW,8BAAQ,GAAG;IACxB,4CAA4C;IAC5C,yDAAyD;CACzD,CAAC;AAEY,0BAAI,GAAG;IACpB,MAAM,EAAE,WAAI,CAAC,MAAM,CAAC;QACnB,WAAW,EAAE,0CAA0C;QACvD,QAAQ,EAAE,IAAI;KACd,CAAC;IACF,OAAO,EAAE,WAAI,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,mCAAmC;KAChD,CAAC;CACF,CAAC;AAEY,mCAAa,GAAG,IAAI,CAAC;kBAvBf,qBAAqB"}
@@ -0,0 +1,13 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class OrganizationRmCmd extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ handle: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ yes: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ static authenticated: boolean;
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const cf = require("../../utils/common-flags");
5
+ const lazy_1 = require("../../utils/lazy");
6
+ class OrganizationRmCmd extends core_1.Command {
7
+ async run() {
8
+ const { args: params, flags: options } = await this.parse(OrganizationRmCmd);
9
+ const balena = (0, lazy_1.getBalenaSdk)();
10
+ const patterns = await Promise.resolve().then(() => require('../../utils/patterns'));
11
+ const org = await balena.models.organization.get(params.handle, {
12
+ $select: ['id', 'name'],
13
+ });
14
+ await patterns.confirm(options.yes, `Are you sure you want to delete organization '${org.name}' with handle '${params.handle}' ?`);
15
+ await balena.models.organization.remove(org.id);
16
+ }
17
+ }
18
+ OrganizationRmCmd.description = (0, lazy_1.stripIndent) `
19
+ Remove an organizations.
20
+
21
+ Remove an organizations from balena.
22
+
23
+ Note this command asks for confirmation interactively.
24
+ You can avoid this by passing the \`--yes\` option.
25
+ `;
26
+ OrganizationRmCmd.examples = [
27
+ '$ balena organization rm my_org_handle',
28
+ '$ balena organization rm my_org_handle --yes',
29
+ ];
30
+ OrganizationRmCmd.args = {
31
+ handle: core_1.Args.string({
32
+ description: 'the handle of the organization to delete',
33
+ required: true,
34
+ }),
35
+ };
36
+ OrganizationRmCmd.flags = {
37
+ yes: cf.yes(),
38
+ };
39
+ OrganizationRmCmd.authenticated = true;
40
+ exports.default = OrganizationRmCmd;
41
+ //# sourceMappingURL=rm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rm.js","sourceRoot":"","sources":["../../../src/commands/organization/rm.ts"],"names":[],"mappings":";;AAiBA,sCAA4C;AAC5C,+CAA+C;AAC/C,2CAA6D;AAE7D,MAAqB,iBAAkB,SAAQ,cAAO;IA2B9C,KAAK,CAAC,GAAG;QACf,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GACrC,MAAM,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAErC,MAAM,MAAM,GAAG,IAAA,mBAAY,GAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,2CAAa,sBAAsB,EAAC,CAAC;QAGtD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;YAC/D,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC;SACvB,CAAC,CAAC;QAEH,MAAM,QAAQ,CAAC,OAAO,CACrB,OAAO,CAAC,GAAG,EACX,iDAAiD,GAAG,CAAC,IAAI,kBAAkB,MAAM,CAAC,MAAM,KAAK,CAC7F,CAAC;QAEF,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC;;AA5Ca,6BAAW,GAAG,IAAA,kBAAW,EAAA;;;;;;;GAOrC,CAAC;AACW,0BAAQ,GAAG;IACxB,wCAAwC;IACxC,8CAA8C;CAC9C,CAAC;AAEY,sBAAI,GAAG;IACpB,MAAM,EAAE,WAAI,CAAC,MAAM,CAAC;QACnB,WAAW,EAAE,0CAA0C;QACvD,QAAQ,EAAE,IAAI;KACd,CAAC;CACF,CAAC;AAEY,uBAAK,GAAG;IACrB,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE;CACb,CAAC;AAEY,+BAAa,GAAG,IAAI,CAAC;kBAzBf,iBAAiB"}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "balena-cli",
3
- "version": "25.0.0",
3
+ "version": "25.1.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "balena-cli",
9
- "version": "25.0.0",
9
+ "version": "25.1.0",
10
10
  "hasInstallScript": true,
11
11
  "license": "Apache-2.0",
12
12
  "dependencies": {
@@ -3233,6 +3233,37 @@
3233
3233
  "index.js"
3234
3234
  ]
3235
3235
  },
3236
+ "organization:create": {
3237
+ "aliases": [],
3238
+ "args": {
3239
+ "orgName": {
3240
+ "description": "the name to use for the new organization",
3241
+ "name": "orgName",
3242
+ "required": true
3243
+ }
3244
+ },
3245
+ "description": "Create an organization.\n\nCreate a new organization.",
3246
+ "examples": [
3247
+ "$ balena organization create MyOrg"
3248
+ ],
3249
+ "flags": {},
3250
+ "hasDynamicHelp": false,
3251
+ "hiddenAliases": [],
3252
+ "id": "organization:create",
3253
+ "pluginAlias": "balena-cli",
3254
+ "pluginName": "balena-cli",
3255
+ "pluginType": "core",
3256
+ "strict": true,
3257
+ "enableJsonFlag": false,
3258
+ "authenticated": true,
3259
+ "isESM": false,
3260
+ "relativePath": [
3261
+ "build",
3262
+ "commands",
3263
+ "organization",
3264
+ "create.js"
3265
+ ]
3266
+ },
3236
3267
  "organization:list": {
3237
3268
  "aliases": [],
3238
3269
  "args": {},
@@ -3258,134 +3289,80 @@
3258
3289
  "list.js"
3259
3290
  ]
3260
3291
  },
3261
- "preload": {
3292
+ "organization:rename": {
3262
3293
  "aliases": [],
3263
3294
  "args": {
3264
- "image": {
3265
- "description": "the image file path",
3266
- "name": "image",
3295
+ "handle": {
3296
+ "description": "the handle of the organization to rename",
3297
+ "name": "handle",
3267
3298
  "required": true
3299
+ },
3300
+ "newName": {
3301
+ "description": "the new name for the organization",
3302
+ "name": "newName"
3268
3303
  }
3269
3304
  },
3270
- "description": "Preload a release on a disk image (or Edison zip archive).\n\nPreload a release (service images/containers) from a balena fleet, and optionally\na balenaOS splash screen, in a previously downloaded '.img' balenaOS image file\nin the local disk (a zip file is only accepted for the Intel Edison device type).\nAfter preloading, the balenaOS image file can be flashed to a device's SD card.\nWhen the device boots, it will not need to download the release, as it was\npreloaded. This is usually combined with release pinning\n(https://www.balena.io/docs/learn/deploy/release-strategy/release-policy/)\nto avoid the device downloading a newer release straight away, if available.\nCheck also the Preloading and Preregistering section of the balena CLI's advanced\nmasterclass document:\nhttps://www.balena.io/docs/learn/more/masterclasses/advanced-cli/#5-preloading-and-preregistering\n\nFleets may be specified by fleet name or slug. Fleet slugs are\nthe recommended option, as they are unique and unambiguous. Slugs can be\nlisted with the `balena fleet list` command. Note that slugs may change if the\nfleet is renamed. Fleet names are not unique and may result in \"Fleet is\nambiguous\" errors at any time (even if it \"used to work in the past\"), for\nexample if the name clashes with a newly created public fleet, or with fleets\nfrom other balena accounts that you may be invited to join under any role.\nFor this reason, fleet names are especially discouraged in scripts (e.g. CI\nenvironments).\n\nNote that the this command requires Docker to be installed, as further detailed\nin the balena CLI's installation instructions:\nhttps://github.com/balena-io/balena-cli/blob/master/INSTALL.md\nThe `--dockerHost` and `--dockerPort` flags allow a remote Docker engine to\nbe used, however the image file must be accessible to the remote Docker engine\non the same path given on the command line. This is because Docker's bind mount\nfeature is used to \"share\" the image with a container that performs the preload.",
3305
+ "description": "Rename an organization.\n\nRename an organization.\n\nNote, if the name is omitted, it will be prompted for interactively.",
3271
3306
  "examples": [
3272
- "$ balena preload balena.img --fleet MyFleet --commit e1f2592fc6ee949e68756d4f4a48e49bff8d72a0",
3273
- "$ balena preload balena.img --fleet myorg/myfleet --splash-image image.png",
3274
- "$ balena preload balena.img"
3307
+ "$ balena organization rename my_org_handle",
3308
+ "$ balena organization rename my_org_handle \"My New Org\""
3309
+ ],
3310
+ "flags": {},
3311
+ "hasDynamicHelp": false,
3312
+ "hiddenAliases": [],
3313
+ "id": "organization:rename",
3314
+ "pluginAlias": "balena-cli",
3315
+ "pluginName": "balena-cli",
3316
+ "pluginType": "core",
3317
+ "strict": true,
3318
+ "enableJsonFlag": false,
3319
+ "authenticated": true,
3320
+ "isESM": false,
3321
+ "relativePath": [
3322
+ "build",
3323
+ "commands",
3324
+ "organization",
3325
+ "rename.js"
3326
+ ]
3327
+ },
3328
+ "organization:rm": {
3329
+ "aliases": [],
3330
+ "args": {
3331
+ "handle": {
3332
+ "description": "the handle of the organization to delete",
3333
+ "name": "handle",
3334
+ "required": true
3335
+ }
3336
+ },
3337
+ "description": "Remove an organizations.\n\nRemove an organizations from balena.\n\nNote this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` option.",
3338
+ "examples": [
3339
+ "$ balena organization rm my_org_handle",
3340
+ "$ balena organization rm my_org_handle --yes"
3275
3341
  ],
3276
3342
  "flags": {
3277
- "fleet": {
3278
- "char": "f",
3279
- "description": "fleet name or slug (preferred)",
3280
- "name": "fleet",
3281
- "hasDynamicHelp": false,
3282
- "multiple": false,
3283
- "type": "option"
3284
- },
3285
- "commit": {
3286
- "char": "c",
3287
- "description": "The commit hash of the release to preload. Use \"current\" to specify the current\nrelease (ignored if no appId is given). The current release is usually also the\nlatest, but can be pinned to a specific release. See:\nhttps://www.balena.io/docs/learn/deploy/release-strategy/release-policy/\nhttps://www.balena.io/docs/learn/more/masterclasses/fleet-management/#63-pin-using-the-api\nhttps://github.com/balena-io-examples/staged-releases",
3288
- "name": "commit",
3289
- "hasDynamicHelp": false,
3290
- "multiple": false,
3291
- "type": "option"
3292
- },
3293
- "splash-image": {
3294
- "char": "s",
3295
- "description": "path to a png image to replace the splash screen",
3296
- "name": "splash-image",
3297
- "hasDynamicHelp": false,
3298
- "multiple": false,
3299
- "type": "option"
3300
- },
3301
- "dont-check-arch": {
3302
- "description": "disable architecture compatibility check between image and fleet",
3303
- "name": "dont-check-arch",
3343
+ "yes": {
3344
+ "char": "y",
3345
+ "description": "answer \"yes\" to all questions (non interactive use)",
3346
+ "name": "yes",
3304
3347
  "allowNo": false,
3305
3348
  "type": "boolean"
3306
- },
3307
- "pin-device-to-release": {
3308
- "char": "p",
3309
- "description": "pin the preloaded device to the preloaded release on provision",
3310
- "name": "pin-device-to-release",
3311
- "allowNo": true,
3312
- "type": "boolean"
3313
- },
3314
- "additional-space": {
3315
- "description": "expand the image by this amount of bytes instead of automatically estimating the required amount",
3316
- "name": "additional-space",
3317
- "hasDynamicHelp": false,
3318
- "multiple": false,
3319
- "type": "option"
3320
- },
3321
- "add-certificate": {
3322
- "description": "Add the given certificate (in PEM format) to /etc/ssl/certs in the preloading container.\nThe file name must end with '.crt' and must not be already contained in the preloader's\n/etc/ssl/certs folder.\nCan be repeated to add multiple certificates.",
3323
- "name": "add-certificate",
3324
- "hasDynamicHelp": false,
3325
- "multiple": true,
3326
- "type": "option"
3327
- },
3328
- "docker": {
3329
- "char": "P",
3330
- "description": "Path to a local docker socket (e.g. /var/run/docker.sock)",
3331
- "name": "docker",
3332
- "hasDynamicHelp": false,
3333
- "multiple": false,
3334
- "type": "option"
3335
- },
3336
- "dockerHost": {
3337
- "char": "h",
3338
- "description": "Docker daemon hostname or IP address (dev machine or balena device) ",
3339
- "name": "dockerHost",
3340
- "hasDynamicHelp": false,
3341
- "multiple": false,
3342
- "type": "option"
3343
- },
3344
- "dockerPort": {
3345
- "description": "Docker daemon TCP port number (hint: 2375 for balena devices)",
3346
- "name": "dockerPort",
3347
- "hasDynamicHelp": false,
3348
- "multiple": false,
3349
- "type": "option"
3350
- },
3351
- "ca": {
3352
- "description": "Docker host TLS certificate authority file",
3353
- "name": "ca",
3354
- "hasDynamicHelp": false,
3355
- "multiple": false,
3356
- "type": "option"
3357
- },
3358
- "cert": {
3359
- "description": "Docker host TLS certificate file",
3360
- "name": "cert",
3361
- "hasDynamicHelp": false,
3362
- "multiple": false,
3363
- "type": "option"
3364
- },
3365
- "key": {
3366
- "description": "Docker host TLS key file",
3367
- "name": "key",
3368
- "hasDynamicHelp": false,
3369
- "multiple": false,
3370
- "type": "option"
3371
3349
  }
3372
3350
  },
3373
3351
  "hasDynamicHelp": false,
3374
3352
  "hiddenAliases": [],
3375
- "id": "preload",
3353
+ "id": "organization:rm",
3376
3354
  "pluginAlias": "balena-cli",
3377
3355
  "pluginName": "balena-cli",
3378
3356
  "pluginType": "core",
3379
3357
  "strict": true,
3380
3358
  "enableJsonFlag": false,
3381
3359
  "authenticated": true,
3382
- "primary": true,
3383
3360
  "isESM": false,
3384
3361
  "relativePath": [
3385
3362
  "build",
3386
3363
  "commands",
3387
- "preload",
3388
- "index.js"
3364
+ "organization",
3365
+ "rm.js"
3389
3366
  ]
3390
3367
  },
3391
3368
  "os:configure": {
@@ -3903,186 +3880,134 @@
3903
3880
  "index.js"
3904
3881
  ]
3905
3882
  },
3906
- "release:finalize": {
3907
- "aliases": [],
3908
- "args": {
3909
- "commitOrId": {
3910
- "description": "the commit or ID of the release to finalize",
3911
- "name": "commitOrId",
3912
- "required": true
3913
- }
3914
- },
3915
- "description": "Finalize a release.\n\nFinalize a release. Releases can be \"draft\" or \"final\", and this command\nchanges a draft release into a final release. Draft releases can be created\nwith the `--draft` option of the `balena build` or `balena deploy`\ncommands.\n\nDraft releases are not automatically deployed to devices tracking the latest\nrelease. For a draft release to be deployed to a device, the device should be\nexplicity pinned to that release. Conversely, final releases may trigger immediate\ndeployment to unpinned devices (subject to a device's polling period) and, for\nthis reason, final releases cannot be changed back to draft status.",
3916
- "examples": [
3917
- "$ balena release finalize a777f7345fe3d655c1c981aa642e5555",
3918
- "$ balena release finalize 1234567"
3919
- ],
3920
- "flags": {},
3921
- "hasDynamicHelp": false,
3922
- "hiddenAliases": [],
3923
- "id": "release:finalize",
3924
- "pluginAlias": "balena-cli",
3925
- "pluginName": "balena-cli",
3926
- "pluginType": "core",
3927
- "strict": true,
3928
- "enableJsonFlag": false,
3929
- "authenticated": true,
3930
- "isESM": false,
3931
- "relativePath": [
3932
- "build",
3933
- "commands",
3934
- "release",
3935
- "finalize.js"
3936
- ]
3937
- },
3938
- "release": {
3883
+ "preload": {
3939
3884
  "aliases": [],
3940
3885
  "args": {
3941
- "commitOrId": {
3942
- "description": "the commit or ID of the release to get information",
3943
- "name": "commitOrId",
3886
+ "image": {
3887
+ "description": "the image file path",
3888
+ "name": "image",
3944
3889
  "required": true
3945
3890
  }
3946
3891
  },
3947
- "description": "Get info for a release.",
3892
+ "description": "Preload a release on a disk image (or Edison zip archive).\n\nPreload a release (service images/containers) from a balena fleet, and optionally\na balenaOS splash screen, in a previously downloaded '.img' balenaOS image file\nin the local disk (a zip file is only accepted for the Intel Edison device type).\nAfter preloading, the balenaOS image file can be flashed to a device's SD card.\nWhen the device boots, it will not need to download the release, as it was\npreloaded. This is usually combined with release pinning\n(https://www.balena.io/docs/learn/deploy/release-strategy/release-policy/)\nto avoid the device downloading a newer release straight away, if available.\nCheck also the Preloading and Preregistering section of the balena CLI's advanced\nmasterclass document:\nhttps://www.balena.io/docs/learn/more/masterclasses/advanced-cli/#5-preloading-and-preregistering\n\nFleets may be specified by fleet name or slug. Fleet slugs are\nthe recommended option, as they are unique and unambiguous. Slugs can be\nlisted with the `balena fleet list` command. Note that slugs may change if the\nfleet is renamed. Fleet names are not unique and may result in \"Fleet is\nambiguous\" errors at any time (even if it \"used to work in the past\"), for\nexample if the name clashes with a newly created public fleet, or with fleets\nfrom other balena accounts that you may be invited to join under any role.\nFor this reason, fleet names are especially discouraged in scripts (e.g. CI\nenvironments).\n\nNote that the this command requires Docker to be installed, as further detailed\nin the balena CLI's installation instructions:\nhttps://github.com/balena-io/balena-cli/blob/master/INSTALL.md\nThe `--dockerHost` and `--dockerPort` flags allow a remote Docker engine to\nbe used, however the image file must be accessible to the remote Docker engine\non the same path given on the command line. This is because Docker's bind mount\nfeature is used to \"share\" the image with a container that performs the preload.",
3948
3893
  "examples": [
3949
- "$ balena release a777f7345fe3d655c1c981aa642e5555",
3950
- "$ balena release 1234567"
3894
+ "$ balena preload balena.img --fleet MyFleet --commit e1f2592fc6ee949e68756d4f4a48e49bff8d72a0",
3895
+ "$ balena preload balena.img --fleet myorg/myfleet --splash-image image.png",
3896
+ "$ balena preload balena.img"
3951
3897
  ],
3952
3898
  "flags": {
3953
- "json": {
3954
- "description": "Format output as json.",
3955
- "helpGroup": "GLOBAL",
3956
- "name": "json",
3957
- "allowNo": false,
3958
- "type": "boolean"
3959
- },
3960
- "composition": {
3961
- "char": "c",
3962
- "description": "Return the release composition",
3963
- "name": "composition",
3964
- "allowNo": false,
3965
- "type": "boolean"
3966
- }
3967
- },
3968
- "hasDynamicHelp": false,
3969
- "hiddenAliases": [],
3970
- "id": "release",
3971
- "pluginAlias": "balena-cli",
3972
- "pluginName": "balena-cli",
3973
- "pluginType": "core",
3974
- "strict": true,
3975
- "enableJsonFlag": true,
3976
- "authenticated": true,
3977
- "isESM": false,
3978
- "relativePath": [
3979
- "build",
3980
- "commands",
3981
- "release",
3982
- "index.js"
3983
- ]
3984
- },
3985
- "release:invalidate": {
3986
- "aliases": [],
3987
- "args": {
3988
- "commitOrId": {
3989
- "description": "the commit or ID of the release to invalidate",
3990
- "name": "commitOrId",
3991
- "required": true
3992
- }
3993
- },
3994
- "description": "Invalidate a release.\n\nInvalidate a release.\n\nInvalid releases are not automatically deployed to devices tracking the latest\nrelease. For an invalid release to be deployed to a device, the device should be\nexplicity pinned to that release.",
3995
- "examples": [
3996
- "$ balena release invalidate a777f7345fe3d655c1c981aa642e5555",
3997
- "$ balena release invalidate 1234567"
3998
- ],
3999
- "flags": {},
4000
- "hasDynamicHelp": false,
4001
- "hiddenAliases": [],
4002
- "id": "release:invalidate",
4003
- "pluginAlias": "balena-cli",
4004
- "pluginName": "balena-cli",
4005
- "pluginType": "core",
4006
- "strict": true,
4007
- "enableJsonFlag": false,
4008
- "authenticated": true,
4009
- "isESM": false,
4010
- "relativePath": [
4011
- "build",
4012
- "commands",
4013
- "release",
4014
- "invalidate.js"
4015
- ]
4016
- },
4017
- "release:list": {
4018
- "aliases": [],
4019
- "args": {
4020
3899
  "fleet": {
3900
+ "char": "f",
4021
3901
  "description": "fleet name or slug (preferred)",
4022
3902
  "name": "fleet",
4023
- "required": true
4024
- }
4025
- },
4026
- "description": "List all releases of a fleet.\n\nList all releases of the given fleet.\n\nFleets may be specified by fleet name or slug. Slugs are recommended because\nthey are unique and unambiguous. Slugs can be listed with the `balena fleet list`\ncommand. Note that slugs may change if the fleet is renamed. Fleet names are\nnot unique and may result in \"Fleet is ambiguous\" errors at any time (even if\n\"it used to work in the past\"), for example if the name clashes with a newly\ncreated public/open fleet, or with fleets from other balena accounts that you\nmay be invited to join under any role. For this reason, fleet names are\nespecially discouraged in scripts (e.g. CI environments).",
4027
- "examples": [
4028
- "$ balena release list myorg/myfleet"
4029
- ],
4030
- "flags": {
4031
- "json": {
4032
- "description": "Format output as json.",
4033
- "helpGroup": "GLOBAL",
4034
- "name": "json",
3903
+ "hasDynamicHelp": false,
3904
+ "multiple": false,
3905
+ "type": "option"
3906
+ },
3907
+ "commit": {
3908
+ "char": "c",
3909
+ "description": "The commit hash of the release to preload. Use \"current\" to specify the current\nrelease (ignored if no appId is given). The current release is usually also the\nlatest, but can be pinned to a specific release. See:\nhttps://www.balena.io/docs/learn/deploy/release-strategy/release-policy/\nhttps://www.balena.io/docs/learn/more/masterclasses/fleet-management/#63-pin-using-the-api\nhttps://github.com/balena-io-examples/staged-releases",
3910
+ "name": "commit",
3911
+ "hasDynamicHelp": false,
3912
+ "multiple": false,
3913
+ "type": "option"
3914
+ },
3915
+ "splash-image": {
3916
+ "char": "s",
3917
+ "description": "path to a png image to replace the splash screen",
3918
+ "name": "splash-image",
3919
+ "hasDynamicHelp": false,
3920
+ "multiple": false,
3921
+ "type": "option"
3922
+ },
3923
+ "dont-check-arch": {
3924
+ "description": "disable architecture compatibility check between image and fleet",
3925
+ "name": "dont-check-arch",
4035
3926
  "allowNo": false,
4036
3927
  "type": "boolean"
3928
+ },
3929
+ "pin-device-to-release": {
3930
+ "char": "p",
3931
+ "description": "pin the preloaded device to the preloaded release on provision",
3932
+ "name": "pin-device-to-release",
3933
+ "allowNo": true,
3934
+ "type": "boolean"
3935
+ },
3936
+ "additional-space": {
3937
+ "description": "expand the image by this amount of bytes instead of automatically estimating the required amount",
3938
+ "name": "additional-space",
3939
+ "hasDynamicHelp": false,
3940
+ "multiple": false,
3941
+ "type": "option"
3942
+ },
3943
+ "add-certificate": {
3944
+ "description": "Add the given certificate (in PEM format) to /etc/ssl/certs in the preloading container.\nThe file name must end with '.crt' and must not be already contained in the preloader's\n/etc/ssl/certs folder.\nCan be repeated to add multiple certificates.",
3945
+ "name": "add-certificate",
3946
+ "hasDynamicHelp": false,
3947
+ "multiple": true,
3948
+ "type": "option"
3949
+ },
3950
+ "docker": {
3951
+ "char": "P",
3952
+ "description": "Path to a local docker socket (e.g. /var/run/docker.sock)",
3953
+ "name": "docker",
3954
+ "hasDynamicHelp": false,
3955
+ "multiple": false,
3956
+ "type": "option"
3957
+ },
3958
+ "dockerHost": {
3959
+ "char": "h",
3960
+ "description": "Docker daemon hostname or IP address (dev machine or balena device) ",
3961
+ "name": "dockerHost",
3962
+ "hasDynamicHelp": false,
3963
+ "multiple": false,
3964
+ "type": "option"
3965
+ },
3966
+ "dockerPort": {
3967
+ "description": "Docker daemon TCP port number (hint: 2375 for balena devices)",
3968
+ "name": "dockerPort",
3969
+ "hasDynamicHelp": false,
3970
+ "multiple": false,
3971
+ "type": "option"
3972
+ },
3973
+ "ca": {
3974
+ "description": "Docker host TLS certificate authority file",
3975
+ "name": "ca",
3976
+ "hasDynamicHelp": false,
3977
+ "multiple": false,
3978
+ "type": "option"
3979
+ },
3980
+ "cert": {
3981
+ "description": "Docker host TLS certificate file",
3982
+ "name": "cert",
3983
+ "hasDynamicHelp": false,
3984
+ "multiple": false,
3985
+ "type": "option"
3986
+ },
3987
+ "key": {
3988
+ "description": "Docker host TLS key file",
3989
+ "name": "key",
3990
+ "hasDynamicHelp": false,
3991
+ "multiple": false,
3992
+ "type": "option"
4037
3993
  }
4038
3994
  },
4039
3995
  "hasDynamicHelp": false,
4040
3996
  "hiddenAliases": [],
4041
- "id": "release:list",
4042
- "pluginAlias": "balena-cli",
4043
- "pluginName": "balena-cli",
4044
- "pluginType": "core",
4045
- "strict": true,
4046
- "enableJsonFlag": true,
4047
- "authenticated": true,
4048
- "isESM": false,
4049
- "relativePath": [
4050
- "build",
4051
- "commands",
4052
- "release",
4053
- "list.js"
4054
- ]
4055
- },
4056
- "release:validate": {
4057
- "aliases": [],
4058
- "args": {
4059
- "commitOrId": {
4060
- "description": "the commit or ID of the release to validate",
4061
- "name": "commitOrId",
4062
- "required": true
4063
- }
4064
- },
4065
- "description": "Validate a release.\n\nValidate a release.\n\nValid releases are automatically deployed to devices tracking the latest\nrelease if they are finalized.",
4066
- "examples": [
4067
- "$ balena release validate a777f7345fe3d655c1c981aa642e5555",
4068
- "$ balena release validate 1234567"
4069
- ],
4070
- "flags": {},
4071
- "hasDynamicHelp": false,
4072
- "hiddenAliases": [],
4073
- "id": "release:validate",
3997
+ "id": "preload",
4074
3998
  "pluginAlias": "balena-cli",
4075
3999
  "pluginName": "balena-cli",
4076
4000
  "pluginType": "core",
4077
4001
  "strict": true,
4078
4002
  "enableJsonFlag": false,
4079
4003
  "authenticated": true,
4004
+ "primary": true,
4080
4005
  "isESM": false,
4081
4006
  "relativePath": [
4082
4007
  "build",
4083
4008
  "commands",
4084
- "release",
4085
- "validate.js"
4009
+ "preload",
4010
+ "index.js"
4086
4011
  ]
4087
4012
  },
4088
4013
  "release-asset:delete": {
@@ -4300,6 +4225,188 @@
4300
4225
  "upload.js"
4301
4226
  ]
4302
4227
  },
4228
+ "release:finalize": {
4229
+ "aliases": [],
4230
+ "args": {
4231
+ "commitOrId": {
4232
+ "description": "the commit or ID of the release to finalize",
4233
+ "name": "commitOrId",
4234
+ "required": true
4235
+ }
4236
+ },
4237
+ "description": "Finalize a release.\n\nFinalize a release. Releases can be \"draft\" or \"final\", and this command\nchanges a draft release into a final release. Draft releases can be created\nwith the `--draft` option of the `balena build` or `balena deploy`\ncommands.\n\nDraft releases are not automatically deployed to devices tracking the latest\nrelease. For a draft release to be deployed to a device, the device should be\nexplicity pinned to that release. Conversely, final releases may trigger immediate\ndeployment to unpinned devices (subject to a device's polling period) and, for\nthis reason, final releases cannot be changed back to draft status.",
4238
+ "examples": [
4239
+ "$ balena release finalize a777f7345fe3d655c1c981aa642e5555",
4240
+ "$ balena release finalize 1234567"
4241
+ ],
4242
+ "flags": {},
4243
+ "hasDynamicHelp": false,
4244
+ "hiddenAliases": [],
4245
+ "id": "release:finalize",
4246
+ "pluginAlias": "balena-cli",
4247
+ "pluginName": "balena-cli",
4248
+ "pluginType": "core",
4249
+ "strict": true,
4250
+ "enableJsonFlag": false,
4251
+ "authenticated": true,
4252
+ "isESM": false,
4253
+ "relativePath": [
4254
+ "build",
4255
+ "commands",
4256
+ "release",
4257
+ "finalize.js"
4258
+ ]
4259
+ },
4260
+ "release": {
4261
+ "aliases": [],
4262
+ "args": {
4263
+ "commitOrId": {
4264
+ "description": "the commit or ID of the release to get information",
4265
+ "name": "commitOrId",
4266
+ "required": true
4267
+ }
4268
+ },
4269
+ "description": "Get info for a release.",
4270
+ "examples": [
4271
+ "$ balena release a777f7345fe3d655c1c981aa642e5555",
4272
+ "$ balena release 1234567"
4273
+ ],
4274
+ "flags": {
4275
+ "json": {
4276
+ "description": "Format output as json.",
4277
+ "helpGroup": "GLOBAL",
4278
+ "name": "json",
4279
+ "allowNo": false,
4280
+ "type": "boolean"
4281
+ },
4282
+ "composition": {
4283
+ "char": "c",
4284
+ "description": "Return the release composition",
4285
+ "name": "composition",
4286
+ "allowNo": false,
4287
+ "type": "boolean"
4288
+ }
4289
+ },
4290
+ "hasDynamicHelp": false,
4291
+ "hiddenAliases": [],
4292
+ "id": "release",
4293
+ "pluginAlias": "balena-cli",
4294
+ "pluginName": "balena-cli",
4295
+ "pluginType": "core",
4296
+ "strict": true,
4297
+ "enableJsonFlag": true,
4298
+ "authenticated": true,
4299
+ "isESM": false,
4300
+ "relativePath": [
4301
+ "build",
4302
+ "commands",
4303
+ "release",
4304
+ "index.js"
4305
+ ]
4306
+ },
4307
+ "release:invalidate": {
4308
+ "aliases": [],
4309
+ "args": {
4310
+ "commitOrId": {
4311
+ "description": "the commit or ID of the release to invalidate",
4312
+ "name": "commitOrId",
4313
+ "required": true
4314
+ }
4315
+ },
4316
+ "description": "Invalidate a release.\n\nInvalidate a release.\n\nInvalid releases are not automatically deployed to devices tracking the latest\nrelease. For an invalid release to be deployed to a device, the device should be\nexplicity pinned to that release.",
4317
+ "examples": [
4318
+ "$ balena release invalidate a777f7345fe3d655c1c981aa642e5555",
4319
+ "$ balena release invalidate 1234567"
4320
+ ],
4321
+ "flags": {},
4322
+ "hasDynamicHelp": false,
4323
+ "hiddenAliases": [],
4324
+ "id": "release:invalidate",
4325
+ "pluginAlias": "balena-cli",
4326
+ "pluginName": "balena-cli",
4327
+ "pluginType": "core",
4328
+ "strict": true,
4329
+ "enableJsonFlag": false,
4330
+ "authenticated": true,
4331
+ "isESM": false,
4332
+ "relativePath": [
4333
+ "build",
4334
+ "commands",
4335
+ "release",
4336
+ "invalidate.js"
4337
+ ]
4338
+ },
4339
+ "release:list": {
4340
+ "aliases": [],
4341
+ "args": {
4342
+ "fleet": {
4343
+ "description": "fleet name or slug (preferred)",
4344
+ "name": "fleet",
4345
+ "required": true
4346
+ }
4347
+ },
4348
+ "description": "List all releases of a fleet.\n\nList all releases of the given fleet.\n\nFleets may be specified by fleet name or slug. Slugs are recommended because\nthey are unique and unambiguous. Slugs can be listed with the `balena fleet list`\ncommand. Note that slugs may change if the fleet is renamed. Fleet names are\nnot unique and may result in \"Fleet is ambiguous\" errors at any time (even if\n\"it used to work in the past\"), for example if the name clashes with a newly\ncreated public/open fleet, or with fleets from other balena accounts that you\nmay be invited to join under any role. For this reason, fleet names are\nespecially discouraged in scripts (e.g. CI environments).",
4349
+ "examples": [
4350
+ "$ balena release list myorg/myfleet"
4351
+ ],
4352
+ "flags": {
4353
+ "json": {
4354
+ "description": "Format output as json.",
4355
+ "helpGroup": "GLOBAL",
4356
+ "name": "json",
4357
+ "allowNo": false,
4358
+ "type": "boolean"
4359
+ }
4360
+ },
4361
+ "hasDynamicHelp": false,
4362
+ "hiddenAliases": [],
4363
+ "id": "release:list",
4364
+ "pluginAlias": "balena-cli",
4365
+ "pluginName": "balena-cli",
4366
+ "pluginType": "core",
4367
+ "strict": true,
4368
+ "enableJsonFlag": true,
4369
+ "authenticated": true,
4370
+ "isESM": false,
4371
+ "relativePath": [
4372
+ "build",
4373
+ "commands",
4374
+ "release",
4375
+ "list.js"
4376
+ ]
4377
+ },
4378
+ "release:validate": {
4379
+ "aliases": [],
4380
+ "args": {
4381
+ "commitOrId": {
4382
+ "description": "the commit or ID of the release to validate",
4383
+ "name": "commitOrId",
4384
+ "required": true
4385
+ }
4386
+ },
4387
+ "description": "Validate a release.\n\nValidate a release.\n\nValid releases are automatically deployed to devices tracking the latest\nrelease if they are finalized.",
4388
+ "examples": [
4389
+ "$ balena release validate a777f7345fe3d655c1c981aa642e5555",
4390
+ "$ balena release validate 1234567"
4391
+ ],
4392
+ "flags": {},
4393
+ "hasDynamicHelp": false,
4394
+ "hiddenAliases": [],
4395
+ "id": "release:validate",
4396
+ "pluginAlias": "balena-cli",
4397
+ "pluginName": "balena-cli",
4398
+ "pluginType": "core",
4399
+ "strict": true,
4400
+ "enableJsonFlag": false,
4401
+ "authenticated": true,
4402
+ "isESM": false,
4403
+ "relativePath": [
4404
+ "build",
4405
+ "commands",
4406
+ "release",
4407
+ "validate.js"
4408
+ ]
4409
+ },
4303
4410
  "settings": {
4304
4411
  "aliases": [],
4305
4412
  "args": {},
@@ -4740,53 +4847,53 @@
4740
4847
  "set.js"
4741
4848
  ]
4742
4849
  },
4743
- "whoami": {
4850
+ "util:available-drives": {
4744
4851
  "aliases": [],
4745
4852
  "args": {},
4746
- "description": "Display account information for current user.\n\nGet the username and email address of the currently logged in user.",
4747
- "examples": [
4748
- "$ balena whoami"
4749
- ],
4853
+ "description": "List available drives.\n\nList available drives which are usable for writing an OS image to.\nDoes not list system drives.",
4750
4854
  "flags": {},
4751
4855
  "hasDynamicHelp": false,
4752
4856
  "hiddenAliases": [],
4753
- "id": "whoami",
4857
+ "id": "util:available-drives",
4754
4858
  "pluginAlias": "balena-cli",
4755
4859
  "pluginName": "balena-cli",
4756
4860
  "pluginType": "core",
4757
4861
  "strict": true,
4758
4862
  "enableJsonFlag": false,
4759
- "authenticated": true,
4863
+ "offlineCompatible": true,
4760
4864
  "isESM": false,
4761
4865
  "relativePath": [
4762
4866
  "build",
4763
4867
  "commands",
4764
- "whoami",
4765
- "index.js"
4868
+ "util",
4869
+ "available-drives.js"
4766
4870
  ]
4767
4871
  },
4768
- "util:available-drives": {
4872
+ "whoami": {
4769
4873
  "aliases": [],
4770
4874
  "args": {},
4771
- "description": "List available drives.\n\nList available drives which are usable for writing an OS image to.\nDoes not list system drives.",
4875
+ "description": "Display account information for current user.\n\nGet the username and email address of the currently logged in user.",
4876
+ "examples": [
4877
+ "$ balena whoami"
4878
+ ],
4772
4879
  "flags": {},
4773
4880
  "hasDynamicHelp": false,
4774
4881
  "hiddenAliases": [],
4775
- "id": "util:available-drives",
4882
+ "id": "whoami",
4776
4883
  "pluginAlias": "balena-cli",
4777
4884
  "pluginName": "balena-cli",
4778
4885
  "pluginType": "core",
4779
4886
  "strict": true,
4780
4887
  "enableJsonFlag": false,
4781
- "offlineCompatible": true,
4888
+ "authenticated": true,
4782
4889
  "isESM": false,
4783
4890
  "relativePath": [
4784
4891
  "build",
4785
4892
  "commands",
4786
- "util",
4787
- "available-drives.js"
4893
+ "whoami",
4894
+ "index.js"
4788
4895
  ]
4789
4896
  }
4790
4897
  },
4791
- "version": "25.0.0"
4898
+ "version": "25.1.0"
4792
4899
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "balena-cli",
3
- "version": "25.0.0",
3
+ "version": "25.1.0",
4
4
  "description": "The official balena Command Line Interface",
5
5
  "main": "./build/app.js",
6
6
  "homepage": "https://github.com/balena-io/balena-cli",
@@ -258,6 +258,6 @@
258
258
  }
259
259
  },
260
260
  "versionist": {
261
- "publishedAt": "2026-04-28T13:25:32.369Z"
261
+ "publishedAt": "2026-04-28T19:52:11.170Z"
262
262
  }
263
263
  }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2016-2020 Balena Ltd.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import { Args, Command } from '@oclif/core';
19
+ import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
20
+
21
+ export default class OrganizationCreateCmd extends Command {
22
+ public static description = stripIndent`
23
+ Create an organization.
24
+
25
+ Create a new organization.
26
+ `;
27
+
28
+ public static examples = ['$ balena organization create MyOrg'];
29
+
30
+ public static args = {
31
+ orgName: Args.string({
32
+ description: 'the name to use for the new organization',
33
+ required: true,
34
+ }),
35
+ };
36
+
37
+ public static authenticated = true;
38
+
39
+ public async run() {
40
+ const { args: params } = await this.parse(OrganizationCreateCmd);
41
+
42
+ const balena = getBalenaSdk();
43
+ const org = await balena.models.organization.create({
44
+ name: params.orgName,
45
+ });
46
+
47
+ console.log(
48
+ getVisuals().table.vertical(org, ['id', 'name', 'handle', 'created_at']),
49
+ );
50
+ }
51
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2016-2020 Balena Ltd.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import { Args, Command } from '@oclif/core';
19
+ import { getBalenaSdk, stripIndent, getCliForm } from '../../utils/lazy';
20
+
21
+ export default class OrganizationRenameCmd extends Command {
22
+ public static description = stripIndent`
23
+ Rename an organization.
24
+
25
+ Rename an organization.
26
+
27
+ Note, if the name is omitted, it will be prompted for interactively.
28
+ `;
29
+ public static examples = [
30
+ '$ balena organization rename my_org_handle',
31
+ '$ balena organization rename my_org_handle "My New Org"',
32
+ ];
33
+
34
+ public static args = {
35
+ handle: Args.string({
36
+ description: 'the handle of the organization to rename',
37
+ required: true,
38
+ }),
39
+ newName: Args.string({
40
+ description: 'the new name for the organization',
41
+ }),
42
+ };
43
+
44
+ public static authenticated = true;
45
+
46
+ public async run() {
47
+ const { args: params } = await this.parse(OrganizationRenameCmd);
48
+
49
+ const balena = getBalenaSdk();
50
+
51
+ const newName =
52
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
53
+ params.newName ||
54
+ (await getCliForm().ask({
55
+ message: 'How do you want to name this organization?',
56
+ type: 'input',
57
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
58
+ })) ||
59
+ '';
60
+
61
+ const org = await balena.models.organization.get(params.handle, {
62
+ $select: 'id',
63
+ });
64
+ await balena.pine.patch({
65
+ resource: 'organization',
66
+ id: org.id,
67
+ body: {
68
+ name: newName,
69
+ },
70
+ });
71
+ }
72
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2016-2020 Balena Ltd.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import { Args, Command } from '@oclif/core';
19
+ import * as cf from '../../utils/common-flags';
20
+ import { getBalenaSdk, stripIndent } from '../../utils/lazy';
21
+
22
+ export default class OrganizationRmCmd extends Command {
23
+ public static description = stripIndent`
24
+ Remove an organizations.
25
+
26
+ Remove an organizations from balena.
27
+
28
+ Note this command asks for confirmation interactively.
29
+ You can avoid this by passing the \`--yes\` option.
30
+ `;
31
+ public static examples = [
32
+ '$ balena organization rm my_org_handle',
33
+ '$ balena organization rm my_org_handle --yes',
34
+ ];
35
+
36
+ public static args = {
37
+ handle: Args.string({
38
+ description: 'the handle of the organization to delete',
39
+ required: true,
40
+ }),
41
+ };
42
+
43
+ public static flags = {
44
+ yes: cf.yes(),
45
+ };
46
+
47
+ public static authenticated = true;
48
+
49
+ public async run() {
50
+ const { args: params, flags: options } =
51
+ await this.parse(OrganizationRmCmd);
52
+
53
+ const balena = getBalenaSdk();
54
+ const patterns = await import('../../utils/patterns');
55
+
56
+ // Confirm
57
+ const org = await balena.models.organization.get(params.handle, {
58
+ $select: ['id', 'name'],
59
+ });
60
+
61
+ await patterns.confirm(
62
+ options.yes,
63
+ `Are you sure you want to delete organization '${org.name}' with handle '${params.handle}' ?`,
64
+ );
65
+
66
+ await balena.models.organization.remove(org.id);
67
+ }
68
+ }