Skip to content

Commit

Permalink
Tool 2294 ionic package name update (#56)
Browse files Browse the repository at this point in the history
* Use different ionic package names based on major version.

* Use force param for npm to force overwriting existing binary links for a binary with the same name from an other pacakge.

* moving ionic package name resolution to a package.

* dep update

* Update package org due to migration

* Removing uneeded files

* Remove using old build system by default

* If using yarn, remove global package before installing new one.

* Use latest sample app.

* Remove alternative ionic packages if using yarn.

* Adding comment
  • Loading branch information
lpusok authored Jul 3, 2020
1 parent ed12f36 commit fab48be
Show file tree
Hide file tree
Showing 197 changed files with 44,807 additions and 1,771 deletions.
77 changes: 0 additions & 77 deletions CHANGELOG.md

This file was deleted.

69 changes: 46 additions & 23 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 28 additions & 30 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
format_version: 6
format_version: 10
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

app:
Expand All @@ -14,43 +14,33 @@ workflows:
- golint:
- errcheck:
- go-test:
- [email protected]:
inputs:
- node_version: 10.13.0
after_run:
- test-with-npm
- test-with-npm-no-platform-remove
- test-with-yarn

test-with-npm:
envs:
- SAMPLE_APP_URL: https://github.com/bitrise-samples/ionic-conference-app.git
- BRANCH: update
- REMOVE_PLATFORM: true
- USE_NPM: true
after_run:
- _common

test-with-npm-no-platform-remove:
envs:
- SAMPLE_APP_URL: https://github.com/bitrise-samples/ionic-conference-app.git
- BRANCH: update
- REMOVE_PLATFORM: false
- SAMPLE_APP_URL: https://github.com/bitrise-io/ionic-conference-app.git
- BRANCH: latest
- IONIC_VERSION: latest
- USE_NPM: true
after_run:
- _common

test-with-yarn:
envs:
- SAMPLE_APP_URL: https://github.com/bitrise-samples/ionic-conference-app.git
- BRANCH: yarn-test-preadded-platforms
- REMOVE_PLATFORM: false
- SAMPLE_APP_URL: https://github.com/bitrise-io/ionic-conference-app.git
- BRANCH: latest
- IONIC_VERSION: latest
- USE_NPM: false
after_run:
- _common

_common:
steps:
- nvm@1:
inputs:
- node_version: '12'
- script:
inputs:
- content: |-
Expand Down Expand Up @@ -79,37 +69,45 @@ workflows:
git remote add origin "${SAMPLE_APP_URL}"
git fetch || exit 1
[[ -n "${COMMIT}" ]] && git checkout "${COMMIT}" || git checkout "${BRANCH}"
- script:
# Needed to test ionic cordova prepare
run_if: '{{enveq "REMOVE_PLATFORM" "true"}}'
- npm:
run_if: '{{enveq "USE_NPM" "true"}}'
inputs:
- workdir: ./
- command: install
- npm:
# Workaround for https://github.com/ionic-team/ionic-cli/issues/4262
run_if: '{{enveq "USE_NPM" "true"}}'
inputs:
- content: rm -rf ./platforms
- workdir: ./
- command: install "@angular-devkit/build-angular@~0.801.2"
- script:
run_if: '{{enveq "USE_NPM" "false"}}'
inputs:
- content: |-
#!/usr/bin/env bash
rm -rf node_modules; rm package-lock.json || true
- npm:
run_if: '{{enveq "USE_NPM" "true"}}'
# rm -rf node_modules; rm package-lock.json || true
- yarn:
run_if: '{{enveq "USE_NPM" "false"}}'
inputs:
- workdir: ./
- command: install
- yarn:
# Workaround for https://github.com/ionic-team/ionic-cli/issues/4262
run_if: '{{enveq "USE_NPM" "false"}}'
inputs:
- workdir: ./
- command: install
- command: add "@angular-devkit/build-angular@~0.801.2"
- path::./:
title: Step Test
inputs:
- workdir: ./
- target: emulator
- platform: ios,android
- ionic_version: latest
- ionic_version: $IONIC_VERSION
- cordova_version: latest
- ionic_username: $IONIC_USERNAME
- ionic_password: $IONIC_PASSWORD
- options: --verbose -- --buildFlag="-UseModernBuildSystem=0"
- options: --verbose
- change-workdir:
title: Switch back to original working directory
inputs:
Expand Down
41 changes: 41 additions & 0 deletions ionic/ionic.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"regexp"
"strconv"
"strings"

"github.com/bitrise-io/go-utils/command"
Expand Down Expand Up @@ -75,3 +76,43 @@ func PrepareCommand(ionicMajorVersion int) *command.Model {
cmdArgs = append(cmdArgs, "prepare", "--no-build")
return command.New(cmdArgs[0], cmdArgs[1:]...)
}

// PackageNameFromVersion returns either "ionic" or "@ionic/cli" based on the required version
// "ionic" is deprecated: https://www.npmjs.com/package/ionic
// "@ionic/cli" starts from version 6.0.0: https://www.npmjs.com/package/@ionic/cli
func PackageNameFromVersion(version string) (string, error) {
newPackageName := "@ionic/cli"
if version == "latest" {
return newPackageName, nil
}

majorVersion, err := parseMajorVersion(version)
if err != nil {
return newPackageName, err
}

if majorVersion < 6 {
return "ionic", nil
}

return newPackageName, nil
}

func parseMajorVersion(version string) (uint64, error) {
matcher := regexp.MustCompile(`(\d+)(.\d+)*`)
matches := matcher.FindStringSubmatch(version)
if matches == nil {
return 0, fmt.Errorf("failed to parse ionic major version (%s): no match", version)
}

if len(matches) < 2 {
return 0, fmt.Errorf("failed to parse ionic major version (%s): unexpected match", version)
}

majorVersion, err := strconv.ParseUint(matches[1], 10, 64)
if err != nil {
return 0, fmt.Errorf("failed to parse ionic major version (%s): %s", version, err)
}

return majorVersion, nil
}
Loading

0 comments on commit fab48be

Please sign in to comment.