Commit 5b32139d authored by Björn Bartels's avatar Björn Bartels 👩🏻
Browse files

Merge branch 'npm-setup' into 'master'

Npm setup

See merge request !2
parents b92544c7 30f5ba07
Loading
Loading
Loading
Loading

.eslintrc

0 → 100644
+64 −0
Original line number Diff line number Diff line
{
  "env": {
    "browser": true,
    "builtin": true,
    "es6": true,
    "jasmine": true,
    "jquery": true,
    "mocha": true,
    "node": true
  },
  "globals": {
    "Foundation": true
    },
  "parserOptions": {
    "ecmaFeatures": {
      "impliedStrict": true,
      "jsx": false
    },
    "ecmaVersion": 6,
    "sourceType": "module"
  },
  "rules": {
    "block-scoped-var": 2,
    "camelcase": 2,
    "comma-style": [2, "last"],
    "curly": [0, "all"],
    "dot-notation": [
      2,
      {
        "allowKeywords": true
      }
    ],
    "eqeqeq": [2, "allow-null"],
    "guard-for-in": 2,
    "new-cap": 2,
    "no-bitwise": 2,
    "no-caller": 2,
    "no-cond-assign": [2, "except-parens"],
    "no-debugger": 2,
    "no-empty": 2,
    "no-eval": 2,
    "no-extend-native": 2,
    "no-extra-parens": 1,
    "no-irregular-whitespace": 2,
    "no-iterator": 2,
    "no-loop-func": 2,
    "no-multi-str": 2,
    "no-new": 2,
    "no-plusplus": 0,
    "no-proto": 2,
    "no-script-url": 2,
    "no-sequences": 2,
    "no-shadow": 1,
    "no-undef": 2,
    "no-unused-vars": 1,
    "no-with": 2,
    "quotes": 0,
    "radix" : 2,
    "semi": [0, "never"],
    "strict": [1, "global"],
    "valid-typeof": 2,
    "wrap-iife": [2, "inside"]
  }
}
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
.setting*
.nyc*

package-lock.json
node_modules
vendor
dist
+123 −46
Original line number Diff line number Diff line
@@ -4,6 +4,17 @@ stages:
  - test
  - deploy

# Cache modules in between jobs
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    # cache JS dependencies
    - node_modules/
    # cache PHP dependencies
    - vendor/
    # cache package/project stuff, non-artifacts
    - dist/

variables:
  BUILD_TARGET: httpdocs
  BUILD_LABEL_TMPFILE: build.txt
@@ -11,22 +22,31 @@ variables:
before_script:
  - if [ -f ${BUILD_LABEL_TMPFILE} ]; then export BUILD_LABEL=`cat ${BUILD_LABEL_TMPFILE}`; fi


init:
  stage: setup
  tags:
    #- kunden-web
    - kunden-web
    #- node
    - php
    #- php
  before_script:
    - export BUILD_LABEL=$(TZ=Europe/Berlin date +%Y%m%d-%H%M)
  script:
    # save timestamp to file
    - echo $BUILD_LABEL > ${BUILD_LABEL_TMPFILE}
    - echo -e "\n\n\n\e[96mCreated new build label \e[107;30;1m $BUILD_LABEL \e[0m\n\n\n"
    - echo -e "\n\n\e[96mCreated new build label \e[107;30;1m $BUILD_LABEL \e[0m\n\n"
    # other init commands
    - whoami
    - pwd
    - node -v
    - npm -v
    - php -v
    # check if a build environment exists and copy it or install a new one if it doesn't
    - if [ -d /build-env_DOES_NOT_EXIT_USE_INSTALL_FOR_NOW/node_modules ] &&  [ -f /build-env/package-lock.json ];
      then echo -e "\e[96mFOUND EXISTING BUILD ENVIRONMENT" && mv /build-env/* ./;
      else echo -e "\e[93mNO EXISTING BUILD ENVIRONMENT - RUNNING INSTALL" && npm install;
      fi
    # list used packages and info
    - npm ls || true
  artifacts:
    paths:
      - ${BUILD_LABEL_TMPFILE}
@@ -34,29 +54,26 @@ init:
app-build:
  stage: build
  tags:
    #- kunden-web
    - kunden-web
    #- node
    - php
    #- php
  dependencies:
    - init
  variables:
    BUILD_INFO_FILE: httpdocs/build.txt
  script:
    # check if a build environment exists and copy it or install a new one if it doesn't
    - if [ -d /build-env_DOES_NOT_EXIT_USE_INSTALL_FOR_NOW/node_modules ] &&  [ -f /build-env/package-lock.json ];
      then echo -e "\e[96mFOUND EXISTING BUILD ENVIRONMENT" && mv /build-env/* ./;
      else echo -e "\e[93mNO EXISTING BUILD ENVIRONMENT - RUNNING INSTALL" && npm install;
      fi
    # list used packages
    - npm ls || true
    #
    # run no build
    #- echo "Warning - no build specified" && exit 0
    #
    # run node build
    - npm -v
    - php -v
    - npm run build
    # create build info file
    - echo -e "LABEL=`cat ${BUILD_LABEL_TMPFILE}`" > ${BUILD_INFO_FILE}
    - echo -e "TAG=${CI_COMMIT_TAG}" >> ${BUILD_INFO_FILE}
    - echo -e "COMMIT=${CI_COMMIT_SHA}" >> ${BUILD_INFO_FILE}
    - echo -e "PIPELINE=${CI_PIPELINE_ID}" >> ${BUILD_INFO_FILE}
    - echo -e "USER=${GITLAB_USER_NAME} (${GITLAB_USER_LOGIN}) <${GITLAB_USER_EMAIL}>" >> ${BUILD_INFO_FILE}
    # print debug-info
    - cat ${BUILD_INFO_FILE}
    - ls -la ${BUILD_TARGET}
@@ -65,54 +82,104 @@ app-build:
      - ${BUILD_TARGET}


app-tests:
app-test-sass:
  stage: test
  tags:
    #- kunden-web
    #- node
    - php
    - kunden-web
  dependencies:
    - app-build
  variables:
    BUILD_TEST_COVERAGE_FILE: httpdocs/coverage.xml
  script:
    # check if a build environment exists and copy it or install a new one if it doesn't
    - php -v
    - node -v
    #
    # run no tests
    #- echo "Warning - no SASS tests specified" && exit 0
    #
    # run SASS tests
    - npm run test:sass
  artifacts:
    paths:
      - ${BUILD_TARGET}

app-test-javascript:
  stage: test
  tags:
    - kunden-web
  dependencies:
    - app-build
  script:
    #
    # run no tests
    #- echo "Warning - no JavaScript tests specified" && exit 0
    #
    # run SASS tests
    - npm run test:javascript
  artifacts:
    paths:
      - ${BUILD_TARGET}

app-test-browser:
  stage: test
  tags:
    - kunden-web
  dependencies:
    - app-build
  script:
    #
    # run no tests
    #- echo "Warning - no browser tests specified" && exit 0
    #
    # run browser/headless tests
    - npm run test:browser
  artifacts:
    paths:
      - ${BUILD_TARGET}

rsync:
  stage: deploy
src-lint-sass:
  stage: test
  tags:
    - web-rsync-runner
    - kunden-web
  dependencies:
    - app-build
    - app-tests
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - mkdir -p ~/.ssh
    - eval $(ssh-agent -s)
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - ssh-add <(echo "$SSH_STAGING_PRIVATE_KEY")
    - apt-get install rsync
  script:
    - ssh -p22 user@staging.example.com "mkdir -p /_tmp"
    - rsync -rav -e ssh --exclude='.git/' --exclude='.gitlab-ci.yml' --delete-excluded /${BUILD_TARGET}/ user@staging.example.com:/_tmp
    - ssh -p22 user@staging.example.com "mv /${BUILD_TARGET} /${BUILD_TARGET}_save && mv /_tmp /${BUILD_TARGET}"
    - ssh -p22 user@staging.example.com "rm -rf /${BUILD_TARGET}_save"
  only:
    refs:
      - master
  when: manual
    #
    # run no linting
    #- echo "Warning - no SASS linting specified" && exit 0
    #
    # run SASS linting
    - npm run lint:sass
  artifacts:
    paths:
      - ${BUILD_TARGET}

src-lint-javascript:
  stage: test
  tags:
    - kunden-web
  dependencies:
    - app-build
  script:
    #
    # run no linting
    #- echo "Warning - no JavaScript linting specified" && exit 0
    #
    # run SASS linting
    - npm run lint:javascript
  artifacts:
    paths:
      - ${BUILD_TARGET}

# ftp to dev host
ftp-dev:
  stage: deploy
  tags:
    - kunden-web
  dependencies:
    - app-build
    - app-tests
  before_script:
    #- no action for now...
  script:
    # deploy files
    - npm run deploy
    # ftp to host
    - 'which lftp || ( apt-get update -qq && apt-get install -y -qq lftp )'
    - lftp -c "set ftp:ssl-allow no; open -u $FTP_USERNAME,$FTP_PASSWORD $FTP_HOST; mirror -Rev ${BUILD_TARGET}/ ./$FTP_PATH/${BUILD_TARGET}  --parallel=10 --exclude-glob .git* --exclude .git/"
  except:
@@ -121,20 +188,30 @@ ftp-dev:
      - tags
      - release
  when: manual
  artifacts:
    paths:
      - ${BUILD_TARGET}

# ftp to production/live host
ftp-prod:
  stage: deploy
  tags:
    - kunden-web
  dependencies:
    - app-build
    - app-tests
  before_script:
    #- no action for now...
  script:
    # deploy files
    - npm run deploy
    # ftp to host
    - 'which lftp || ( apt-get update -qq && apt-get install -y -qq lftp )'
    - lftp -c "set ftp:ssl-allow no; open -u $FTP_USERNAME_PROD,$FTP_PASSWORD_PROD $FTP_HOST_PROD; mirror -Rev ${BUILD_TARGET}/ ./$FTP_PATH_PROD/${BUILD_TARGET}  --parallel=10 --exclude-glob .git* --exclude .git/"
  only:
    refs:
      - master
      - tags
      - release
  when: manual
  artifacts:
    paths:
      - ${BUILD_TARGET}

.sass-lint.yml

0 → 100644
+96 −0
Original line number Diff line number Diff line
options:
  formatter: stylish
files:
  include: '**/*.s+(a|c)ss'
  ignore: ''
rules:
  # Extends
  extends-before-mixins: 1
  extends-before-declarations: 1
  placeholder-in-extend: 1

  # Mixins
  mixins-before-declarations: 1

  # Line Spacing
  one-declaration-per-line: 1
  empty-line-between-blocks: 1
  single-line-per-selector: 1

  # Disallows
  no-attribute-selectors: 0
  no-color-hex: 0
  no-color-keywords: 1
  no-color-literals: 1
  no-combinators: 0
  no-css-comments: 1
  no-debug: 1
  no-disallowed-properties: 0
  no-duplicate-properties: 1
  no-empty-rulesets: 1
  no-extends: 0
  no-ids: 1
  no-important: 1
  no-invalid-hex: 1
  no-mergeable-selectors: 1
  no-misspelled-properties: 1
  no-qualifying-elements: 1
  no-trailing-whitespace: 1
  no-trailing-zero: 1
  no-transition-all: 1
  no-universal-selectors: 0
  no-url-domains: 1
  no-url-protocols: 1
  no-vendor-prefixes: 1
  no-warn: 1
  property-units: 0

  # Nesting
  declarations-before-nesting: 1
  force-attribute-nesting: 1
  force-element-nesting: 1
  force-pseudo-nesting: 1

  # Name Formats
  class-name-format: 1
  function-name-format: 1
  id-name-format: 0
  mixin-name-format: 1
  placeholder-name-format: 1
  variable-name-format: 1

  # Style Guide
  attribute-quotes: 1
  bem-depth: 0
  border-zero: 1
  brace-style: 1
  clean-import-paths: 1
  empty-args: 1
  hex-length: 1
  hex-notation: 1
  indentation: 1
  leading-zero: 1
  max-line-length: 0
  max-file-line-count: 0
  nesting-depth: 1
  property-sort-order: 1
  pseudo-element: 1
  quotes: 1
  shorthand-values: 1
  url-quotes: 1
  variable-for-property: 1
  zero-unit: 1

  # Inner Spacing
  space-after-comma: 1
  space-before-colon: 1
  space-after-colon: 1
  space-before-brace: 1
  space-before-bang: 1
  space-after-bang: 1
  space-between-parens: 1
  space-around-operator: 1

  # Final Items
  trailing-semicolon: 1
  final-newline: 1
+2 −1
Original line number Diff line number Diff line
{
    "name": "p-ad/web-base",
    "name": "web-base",
    "version": "0.0.1",
    "license": "MIT",
    "require": {}
}
Loading