usf-cli 1.2.8 → 1.2.10

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/index.js CHANGED
@@ -75,8 +75,8 @@ Usage:
75
75
  -c --f=<function-name> create function <function-name> & its test event data template
76
76
  -c --f=<function-name> --t=<template> create function <function-name> with specified template code (see Supported template code) & its test event data template
77
77
  -r --f=<function-name> run function <function-name> with default event data(./uos_test/<function-name>_event.json)
78
- -r --f=<function-name> --e=<event-dir> run function <function-name> with specified event data
79
- -a --id=<app-id> --secret=<service-secret> set app id and service secret for this project (used for generating auth token)
78
+ -r --f=<function-name> --e=<event-file> run function <function-name> with specified event data
79
+ -a [--id=<id> --secret=<secret>] set or show app id and service secret for this project (used for generating auth token)
80
80
  -d upload current stateless functions to UOS platform with UOS auth and deploy automatically
81
81
  -d --installDependency upload current stateless functions to UOS platform with UOS auth and deploy automatically (auto install dependency)
82
82
 
@@ -89,7 +89,7 @@ Supported template code:
89
89
  };
90
90
 
91
91
  const initProject = function () {
92
- spawn("npm", ["init", "-y"], {
92
+ spawn("npm init -y", {
93
93
  shell: true,
94
94
  stdio: "inherit",
95
95
  });
@@ -130,6 +130,14 @@ const runFunction = async function () {
130
130
  };
131
131
 
132
132
  const setAuthInfo = async function () {
133
+ const auth = (await getAuthInfoFromFile()) || {};
134
+ if (!this.id && !this.secret) {
135
+ if (auth.id && auth.secret) {
136
+ console.log(`Current authenticated app id: ${auth.id}`);
137
+ return;
138
+ }
139
+ }
140
+
133
141
  if (!this.id) {
134
142
  console.error(
135
143
  `Please specify app id with "--id".\n\nIf not sure about app id, you can go to uos dev portal(https://uos.unity.cn/apps) to find your apps and get app id.`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usf-cli",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "description": "usf-cli helps uos stateless function developers with local running, boosting their development efficiency.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -78,7 +78,7 @@ const copyFile = async function (dir, folderName, fileName, template) {
78
78
 
79
79
  // auto install dependency of stateless sdk
80
80
  if (repository[template]) {
81
- spawn("npm", ["install", repository[template]], {
81
+ spawn(`npm install ${repository[template]}`, {
82
82
  shell: true,
83
83
  stdio: "inherit",
84
84
  });