@corva/create-app 0.95.0-0 → 0.95.0-rc.0

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.
package/README.md CHANGED
@@ -182,6 +182,7 @@ Options:
182
182
  --silent [boolean] Only log result of the operation (default: false)
183
183
  --remove-on-success App package (.zip) will not be deleted after upload (default: true)
184
184
  --remove-existing [boolean] If package.json version is already taken - remove the previously published package and upload a new one (default: false)
185
+ --author [string] Author name for the audit
185
186
  ```
186
187
 
187
188
  ### Examples
@@ -209,3 +210,9 @@ create-corva-app release test-app --bump-version=patch
209
210
  ```sh
210
211
  create-corva-app release test-app --bump-version=4.2.0
211
212
  ```
213
+
214
+ #### Make a release with author option(by default it will use your GitHub username)
215
+
216
+ ```sh
217
+ create-corva-app release test-app --author=MyName
218
+ ```
@@ -36,7 +36,13 @@ export const releaseCommand = new Command('release')
36
36
  ).default(false),
37
37
  )
38
38
  // .addOption(new Option('--zip-file-name [string]', 'Prebuilt zip file name in dir'))
39
+ .addOption(new Option('--author [string]', 'Author name for the audit'))
39
40
  .action(async (dirName, patterns, options) => {
41
+ // if author is present in CLI, save it to process.env
42
+ if (options.author) {
43
+ process.env.githubUsername = options.author;
44
+ }
45
+
40
46
  options.bumpVersion = await ensureBumpVersion(options.bumpVersion);
41
47
 
42
48
  await runFlow(RELEASE_FLOW, {
@@ -1,5 +1,6 @@
1
1
  import FormData from 'form-data';
2
2
  import chalk from 'chalk';
3
+ import fs from 'fs';
3
4
  import { createReadStream } from 'node:fs';
4
5
  import { resolve } from 'node:path';
5
6
  import { RELEASE } from '../../../constants/messages.js';
@@ -24,9 +25,52 @@ async function deleteAppPackage({ api, appId, appPkgVersion }) {
24
25
  }
25
26
  }
26
27
 
28
+ function getRealAuthorFromGithubEvent() {
29
+ if (!process.env.GITHUB_EVENT_PATH) {
30
+ return null;
31
+ }
32
+
33
+ try {
34
+ const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'));
35
+
36
+ // For push-event
37
+ if (event?.pusher?.name) {
38
+ return event.pusher.name;
39
+ }
40
+
41
+ // For PR event
42
+ if (event?.pull_request?.user?.login) {
43
+ return event.pull_request.user.login;
44
+ }
45
+ } catch (error) {
46
+ // Catch error in case json file is invalid or absent
47
+ return null;
48
+ }
49
+
50
+ return null;
51
+ }
52
+
27
53
  function getGithubUsernameActor() {
28
- // It is fetched from CI github.actor variable
29
- return process.env.githubUsername || null;
54
+ // If option passed --author we firstly take it
55
+ if (process.env.githubUsername) {
56
+ return process.env.githubUsername;
57
+ }
58
+
59
+ // If no --author passed, try use GITHUB_ACTOR
60
+ const actor = process.env.GITHUB_ACTOR;
61
+
62
+ if (actor && actor !== 'github-actions[bot]') {
63
+ return actor;
64
+ }
65
+
66
+ // If actor == github-actions[bot], let's try to get a real user
67
+ const realAuthor = getRealAuthorFromGithubEvent();
68
+
69
+ if (realAuthor) {
70
+ return realAuthor;
71
+ }
72
+
73
+ return null;
30
74
  }
31
75
 
32
76
  function getGitConfigUsername() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.95.0-0",
3
+ "version": "0.95.0-rc.0",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [