@appcircle/codepush-cli 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.eslintrc.json +17 -0
  2. package/.github/pre-push +30 -0
  3. package/.github/prepare-commit--msg +2 -0
  4. package/CONTRIBUTING.md +71 -0
  5. package/Dockerfile +9 -0
  6. package/Jenkinsfile +45 -0
  7. package/README.md +837 -0
  8. package/bin/script/acquisition-sdk.js +178 -0
  9. package/bin/script/cli.js +23 -0
  10. package/bin/script/command-executor.js +1292 -0
  11. package/bin/script/command-parser.js +1123 -0
  12. package/bin/script/commands/debug.js +125 -0
  13. package/bin/script/hash-utils.js +203 -0
  14. package/bin/script/index.js +5 -0
  15. package/bin/script/management-sdk.js +454 -0
  16. package/bin/script/react-native-utils.js +249 -0
  17. package/bin/script/sign.js +69 -0
  18. package/bin/script/types/cli.js +40 -0
  19. package/bin/script/types/rest-definitions.js +19 -0
  20. package/bin/script/types.js +4 -0
  21. package/bin/script/utils/file-utils.js +50 -0
  22. package/bin/test/acquisition-rest-mock.js +108 -0
  23. package/bin/test/acquisition-sdk.js +188 -0
  24. package/bin/test/cli.js +1342 -0
  25. package/bin/test/hash-utils.js +149 -0
  26. package/bin/test/management-sdk.js +338 -0
  27. package/package.json +74 -0
  28. package/prettier.config.js +7 -0
  29. package/script/acquisition-sdk.ts +273 -0
  30. package/script/cli.ts +27 -0
  31. package/script/command-executor.ts +1614 -0
  32. package/script/command-parser.ts +1340 -0
  33. package/script/commands/debug.ts +148 -0
  34. package/script/hash-utils.ts +241 -0
  35. package/script/index.ts +5 -0
  36. package/script/management-sdk.ts +627 -0
  37. package/script/react-native-utils.ts +283 -0
  38. package/script/sign.ts +80 -0
  39. package/script/types/cli.ts +234 -0
  40. package/script/types/rest-definitions.ts +152 -0
  41. package/script/types.ts +35 -0
  42. package/script/utils/check-package.mjs +11 -0
  43. package/script/utils/file-utils.ts +46 -0
  44. package/test/acquisition-rest-mock.ts +125 -0
  45. package/test/acquisition-sdk.ts +272 -0
  46. package/test/cli.ts +1692 -0
  47. package/test/hash-utils.ts +170 -0
  48. package/test/management-sdk.ts +438 -0
  49. package/test/resources/TestApp/android/app/build.gradle +56 -0
  50. package/test/resources/TestApp/iOS/TestApp/Info.plist +49 -0
  51. package/test/resources/TestApp/index.android.js +2 -0
  52. package/test/resources/TestApp/index.ios.js +2 -0
  53. package/test/resources/TestApp/index.windows.js +2 -0
  54. package/test/resources/TestApp/package.json +6 -0
  55. package/test/resources/TestApp/windows/TestApp/Package.appxmanifest +46 -0
  56. package/test/resources/ignoredMetadata.zip +0 -0
  57. package/test/resources/test.zip +0 -0
  58. package/test/superagent-mock-config.js +58 -0
  59. package/tsconfig.json +13 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "parser": "@typescript-eslint/parser",
3
+ "parserOptions": {
4
+ "ecmaVersion": "2022",
5
+ "sourceType": "module",
6
+ "project": "./tsconfig.json"
7
+ },
8
+ "extends": [
9
+ ],
10
+ "rules": {
11
+ "no-var": "error",
12
+ "prefer-const": "error",
13
+ "no-unused-vars": "error",
14
+ "eqeqeq": "error",
15
+ "no-eval": "error"
16
+ }
17
+ }
@@ -0,0 +1,30 @@
1
+ #!/bin/sh
2
+
3
+ protected_branch=main
4
+ branch=$(git rev-parse --abbrev-ref HEAD);
5
+ exit 0;
6
+
7
+ #TODO Check tags names in main branch
8
+
9
+ if [ $protected_branch != $branch ]; then
10
+ echo "IGNORE Checking tags: Pushing to branch $branch"
11
+ else
12
+ echo "Checking unpublished release tags to branch $branch"
13
+ unpublished__release_tags=$(git show-ref --tags | cut -d ' ' -f2,3 | grep -v -F '$(git ls-remote --tags origin | grep -v "\^{}" | cut -f 2)' | grep -E "\-beta*|\-alpa*|\-rc*|\-release*");
14
+ if [[ $unpublished__release_tags ]]; then
15
+ echo "Unpublished release tags found ($unpublished__release_tags)"
16
+ echo "Please remove unpublished release tags in '$branch' to continue to push"
17
+ exit 1;
18
+ #
19
+ #for item in $tags
20
+ #
21
+ #do
22
+ # echo "Attempting removing $item from remote"
23
+
24
+ #done
25
+
26
+ else
27
+ echo "Pushing to branch $branch"
28
+ fi
29
+ fi
30
+ exit 0;
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ exec < /dev/tty && node_modules/.bin/cz --hook || true
@@ -0,0 +1,71 @@
1
+ # Contributing to Appcircle Codepusg Command Line Interface
2
+
3
+ ## Table of Contents
4
+
5
+ - [Table of Contents](#table-of-contents)
6
+ - [How to Contribute](#how-to-contribute)
7
+ - [Publishing Guidelines](#publishing-guidelines)
8
+ - [Jenkins Pipeline](#jenkins-pipeline)
9
+ - [Docker Image](#docker-image)
10
+
11
+
12
+ ## How to Contribute
13
+
14
+ - Clone this repository
15
+ - Install dependencies by using `yarn` command
16
+ - Launch `yarn run watch` to compile & open the project on watch mode
17
+ - Make your changes
18
+ - Submit a PR
19
+
20
+ ## Publishing Guidelines
21
+
22
+ - After changes, run the command `yarn run postversion`. It will push a new tag to the repository.
23
+ - Jenkins will take care of the rest.
24
+
25
+ ### Publishing to NPM
26
+
27
+ To publish a new version on NPM, use the following command:
28
+
29
+ ```shell
30
+ npm version <version>
31
+ ```
32
+
33
+ #### Examples
34
+
35
+ ```shell
36
+ ## To publish a beta version
37
+ $ npm version 1.0.0-beta.1
38
+
39
+ $ npm version 1.0.0
40
+ ```
41
+
42
+ ## Jenkins Pipeline
43
+
44
+ - Jenkins will look for the tag that matches `v*`, `v*-beta*`, `v*-alpha*`.
45
+
46
+ - If a new tag is published, the pipeline will be triggered automatically and publish the application.
47
+
48
+ - If the tag is `v*`, the app will be published to the stable channel.
49
+
50
+ - If the tag is `v*-beta*`, the app will be published to the beta channel.
51
+
52
+ - If the tag is `v*-alpha*`, the app will be published to the alpha channel.
53
+
54
+
55
+ ## Docker Image
56
+
57
+ - Docker image is for building and publishing the application anywhere.
58
+
59
+ - For building and publishing the application to the beta channgel:
60
+
61
+ ```bash
62
+ docker image build -t ac-cli .
63
+ docker run --rm --env NPM_AUTH_TOKEN=abcd ac-cli npm publish --tag beta
64
+ ```
65
+
66
+ - For building and publishing the application to the production:
67
+
68
+ ```bash
69
+ docker image build -t ac-cli --build-arg NPM_AUTH_TOKEN=abcd .
70
+ docker run --rm --env NPM_AUTH_TOKEN=abcd ac-cli npm publish
71
+ ```
package/Dockerfile ADDED
@@ -0,0 +1,9 @@
1
+ FROM node:23-alpine3.20 AS BUILDER
2
+ WORKDIR /app
3
+ COPY package-lock.json .
4
+ COPY package.json .
5
+ RUN npm install
6
+ COPY . .
7
+ # RUN npm run check:package
8
+ RUN npm run build
9
+ RUN echo '//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}' >> ~/.npmrc
package/Jenkinsfile ADDED
@@ -0,0 +1,45 @@
1
+ pipeline {
2
+ agent { label 'agent'}
3
+ environment {
4
+ NPM_AUTH_TOKEN = credentials('Appcircle-Codepush-CLI-NPM-Cred')
5
+ }
6
+ stages {
7
+
8
+ stage('Publish') {
9
+ steps {
10
+ sh '''#!/bin/bash
11
+ # shellcheck shell=bash
12
+ set -x
13
+ set -euo pipefail
14
+ tag=$(git describe --tags --abbrev=0)
15
+ echo "Tag: ${tag}"
16
+
17
+ npmPublishCommand=""
18
+ if [[ "${tag}" == *"beta"* ]]; then
19
+ echo "Beta Release"
20
+ npmPublishCommand="npm publish --tag beta"
21
+ elif [[ "${tag}" == *"alpha"* ]]; then
22
+ echo "Alpha Release"
23
+ npmPublishCommand="npm publish --tag alpha"
24
+ else
25
+ echo "Production Release"
26
+ npmPublishCommand="npm publish"
27
+ fi
28
+
29
+ ## Build the image and make it ready for publishing.
30
+ docker image build -t ac-codepush-cli .
31
+
32
+ ## Publish the application.
33
+ publishStatus=0
34
+ # shellcheck disable=SC2086
35
+ if ! docker run --rm --env NPM_AUTH_TOKEN=${NPM_AUTH_TOKEN} ac-codepush-cli sh -c "npm config set //registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN} && ${npmPublishCommand}"; then
36
+ echo "Publishing failed"
37
+ publishStatus=1
38
+ fi
39
+ docker image rm ac-codepush-cli
40
+ exit $publishStatus
41
+ '''
42
+ }
43
+ }
44
+ }
45
+ }