Skip to content

Commit 2852cb5

Browse files
authored
feat: Add base option for snapcraft (#7320)
1 parent 106e98d commit 2852cb5

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed

Diff for: .changeset/lazy-icons-ring.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": major
3+
---
4+
5+
Add base option for snapcraft

Diff for: docs/configuration/snap.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ The top-level [snap](configuration.md#Configuration-snap) key contains set of op
33
<!-- do not edit. start of generated block -->
44
<ul>
55
<li>
6+
<p><code id="SnapOptions-base">base</code> String | “undefined” - A snap of type base to be used as the execution environment for this snap. Examples: <code>core</code>, <code>core18</code>, <code>core20</code>. Defaults to <code>core18</code></p>
7+
</li>
8+
<li>
69
<p><code id="SnapOptions-confinement">confinement</code> = <code>strict</code> “devmode” | “strict” | “classic” | “undefined” - The type of <a href="https://snapcraft.io/docs/reference/confinement">confinement</a> supported by the snap.</p>
710
</li>
811
<li>

Diff for: packages/app-builder-lib/scheme.json

+7
Original file line numberDiff line numberDiff line change
@@ -5098,6 +5098,13 @@
50985098
"description": "Whether or not the snap should automatically start on login.",
50995099
"type": "boolean"
51005100
},
5101+
"base": {
5102+
"description": "A snap of type base to be used as the execution environment for this snap. Examples: `core`, `core18`, `core20`. Defaults to `core18`",
5103+
"type": [
5104+
"null",
5105+
"string"
5106+
]
5107+
},
51015108
"buildPackages": {
51025109
"anyOf": [
51035110
{

Diff for: packages/app-builder-lib/src/options/SnapOptions.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { TargetSpecificOptions } from "../core"
22
import { CommonLinuxOptions } from "./linuxOptions"
33

44
export interface SnapOptions extends CommonLinuxOptions, TargetSpecificOptions {
5+
/**
6+
* A snap of type base to be used as the execution environment for this snap. Examples: `core`, `core18`, `core20`. Defaults to `core18`
7+
*/
8+
readonly base?: string | null
9+
510
/**
611
* The type of [confinement](https://snapcraft.io/docs/reference/confinement) supported by the snap.
712
* @default strict

Diff for: packages/app-builder-lib/src/targets/snap.ts

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export default class SnapTarget extends Target {
6969
if (this.isUseTemplateApp) {
7070
delete appDescriptor.adapter
7171
}
72+
if (options.base != null) {
73+
snap.base = options.base
74+
}
7275
if (options.grade != null) {
7376
snap.grade = options.grade
7477
}

Diff for: test/src/linux/snapTest.ts

+33
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,39 @@ test.ifDevOrLinuxCi(
296296
})
297297
)
298298

299+
test.ifDevOrLinuxCi(
300+
"default base",
301+
app({
302+
targets: snapTarget,
303+
config: {
304+
productName: "Sep",
305+
},
306+
effectiveOptionComputed: async ({ snap }) => {
307+
expect(snap).toMatchSnapshot()
308+
expect(snap.base).toBe("core18")
309+
return true
310+
},
311+
})
312+
)
313+
314+
test.ifDevOrLinuxCi(
315+
"base option",
316+
app({
317+
targets: snapTarget,
318+
config: {
319+
productName: "Sep",
320+
snap: {
321+
base: "core22",
322+
},
323+
},
324+
effectiveOptionComputed: async ({ snap }) => {
325+
expect(snap).toMatchSnapshot()
326+
expect(snap.base).toBe("core22")
327+
return true
328+
},
329+
})
330+
)
331+
299332
test.ifDevOrLinuxCi(
300333
"use template app",
301334
app({

0 commit comments

Comments
 (0)