diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93646d7..6f7f0e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: + branches: - master tags: - v[0-9]+.[0-9]+.[0-9]+* diff --git a/resources/classic/snapcraft.yaml b/resources/classic/snapcraft.yaml index 6b29c6e..de17e2c 100644 --- a/resources/classic/snapcraft.yaml +++ b/resources/classic/snapcraft.yaml @@ -5,7 +5,7 @@ description: | App description grade: devel -confinement: devmode +confinement: classic apps: electronApp: @@ -24,7 +24,7 @@ apps: TMPDIR: $XDG_RUNTIME_DIR parts: - electron-deps: + electronApp: source: . plugin: nil stage-packages: diff --git a/src/snapcraft.js b/src/snapcraft.js index 904b6b7..be64a19 100644 --- a/src/snapcraft.js +++ b/src/snapcraft.js @@ -55,15 +55,17 @@ class Snapcraft { const args = [command] for (const flag in options) { const value = options[flag] - if (value) { - args.push(`--${flag}=${value}`) - } else { - args.push(`--${flag}`) + if (flag !== 'target-arch') { + if (value) { + args.push(`--${flag}=${value}`) + } else { + args.push(`--${flag}`) + } } } - args.push('--destructive-mode') /* istanbul ignore if */ if (debug.enabled) { + args.push('--destructive-mode') args.push('--debug') } diff --git a/test/snapcraft.js b/test/snapcraft.js index f191655..f2ec5ff 100644 --- a/test/snapcraft.js +++ b/test/snapcraft.js @@ -15,6 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +const debug = require('debug')('electron-installer-snap:snapcraft') const Snapcraft = require('../src/snapcraft') const test = require('ava') @@ -33,5 +34,10 @@ test('generateArgs flags and options', t => { const snapcraft = new Snapcraft() const args = snapcraft.generateArgs('nonexistent', { a: 1, b: null }, ['foo', 'bar']) - t.deepEqual(args, ['nonexistent', '--a=1', '--b', '--destructive-mode', 'foo', 'bar'], 'generated args') + // Note: --destructive-mode and --debug are enabled by default in CI + if (debug.enabled) { + t.deepEqual(args, ['nonexistent', '--a=1', '--b', '--destructive-mode', '--debug', 'foo', 'bar'], 'generated args') + } else { + t.deepEqual(args, ['nonexistent', '--a=1', '--b', 'foo', 'bar'], 'generated args') + } }) diff --git a/test/yaml.js b/test/yaml.js index a32c5c5..2f0ea3a 100644 --- a/test/yaml.js +++ b/test/yaml.js @@ -115,6 +115,41 @@ test('custom app config', async t => { t.true(apps.electronAppName.daemon, 'daemon is set in app') }) +test('strict confinement should apply by default', async t => { + const snapcraftYaml = await createYaml(t, { name: 'electronAppName' }) + t.is(snapcraftYaml.confinement, 'strict') +}) + +test('custom confinement config (devmode should apply correctly)', async t => { + const snapcraftYaml = await createYaml(t, { name: 'electronAppName', confinement: 'devmode' }) + t.is(snapcraftYaml.confinement, 'devmode') +}) + +test('custom confinement config (strict should apply correctly)', async t => { + const snapcraftYaml = await createYaml(t, { name: 'electronAppName', confinement: 'strict' }) + t.is(snapcraftYaml.confinement, 'strict') +}) + +test('custom confinement config (classic should apply correctly)', async t => { + const snapcraftYaml = await createYaml(t, { name: 'electronAppName', confinement: 'classic' }) + t.is(snapcraftYaml.confinement, 'classic') +}) + +test('use gnome extensions with strict confinement', async t => { + const { apps } = await createYaml(t, { name: 'electronAppName' }) + t.deepEqual(apps.electronAppName.extensions, ['gnome-3-34']) +}) + +test('Electron < 2 classic confinement apps use desktop-gtk2', async t => { + const { parts } = await createYaml(t, { name: 'electronAppName', confinement: 'classic' }, '1.8.2') + t.deepEqual(parts.electronAppName.after, ['desktop-gtk2']) +}) + +test('Electron 2 classic confinement apps use desktop-gtk3', async t => { + const { parts } = await createYaml(t, { name: 'electronAppName', confinement: 'classic' }, '2.0.0-beta.1') + t.deepEqual(parts.electronAppName.after, ['desktop-gtk3']) +}) + test('Electron < 4 apps require gconf', async t => { const snapcraftYaml = await createYaml(t, { name: 'electronAppName' }, '1.8.2') assertStagedPackage(t, snapcraftYaml, 'libgconf-2-4')