nodejs / snap

Node.js snap source and updater
MIT License
166 stars 38 forks source link

Yarn dependency from the NodeJS Snap causes conflict with package.json files. #43

Open fostertime opened 2 years ago

fostertime commented 2 years ago

Yarn dependency from the NodeJS Snap causes conflict with package.json files as the Yarn package.json is never removed.

The below snapcraft.yaml is an example of how we are able to get around this, currently. But, is this the best way to handle this situation? Or is there a "best practice" method that we are not following?

name: beta-application
version: git
summary: BETA Application
description: |
  For Ubuntu Core 22 systems with the ubuntu-frame display server.

base: core22
confinement: strict
grade: devel
compression: lzo

architectures:
  - build-on: amd64
  - build-on: armhf
  - build-on: arm64

environment:
  PATH: '$SNAP/bin:$PATH'

apps:
  beta-application:
    command: bin/npm start

parts:
  snapstage:
    plugin: nil
    stage-snaps:
      - node/16/stable
    override-build: |
      craftctl default
      rm ${CRAFT_PART_INSTALL}/package.json
  beta-app:
    plugin: nil
    source: .
    after: [ snapstage ]
    build-environment:
      - PATH: "$PATH:$SNAPCRAFT_PART_BUILD/node_modules/.bin"
    override-build: |
      set +u
      npm install 2>&1
      cp -a src ${CRAFT_PART_INSTALL}
      cp -a node_modules ${CRAFT_PART_INSTALL}
      cp package.json ${CRAFT_PART_INSTALL}
    build-snaps:
      - node/16/stable