@construct-space/cli 1.5.0 → 1.5.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.
- package/dist/index.js +50 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2887,14 +2887,47 @@ function store(creds) {
|
|
|
2887
2887
|
}
|
|
2888
2888
|
function load2() {
|
|
2889
2889
|
const path = credentialsPath();
|
|
2890
|
-
if (
|
|
2891
|
-
|
|
2890
|
+
if (existsSync10(path)) {
|
|
2891
|
+
const data = JSON.parse(readFileSync7(path, "utf-8"));
|
|
2892
|
+
if (data.token)
|
|
2893
|
+
return data;
|
|
2892
2894
|
}
|
|
2893
|
-
const
|
|
2894
|
-
if (
|
|
2895
|
-
|
|
2895
|
+
const fromProfile = loadFromActiveProfile();
|
|
2896
|
+
if (fromProfile)
|
|
2897
|
+
return fromProfile;
|
|
2898
|
+
throw new Error("not logged in \u2014 run 'construct login' first");
|
|
2899
|
+
}
|
|
2900
|
+
function loadFromActiveProfile() {
|
|
2901
|
+
try {
|
|
2902
|
+
const regPath = join12(dataDir(), "profiles.json");
|
|
2903
|
+
if (!existsSync10(regPath))
|
|
2904
|
+
return null;
|
|
2905
|
+
const reg = JSON.parse(readFileSync7(regPath, "utf-8"));
|
|
2906
|
+
const activeId = reg.active_profile;
|
|
2907
|
+
if (!activeId)
|
|
2908
|
+
return null;
|
|
2909
|
+
const authPath = join12(profilesDir(), activeId, "auth.json");
|
|
2910
|
+
if (!existsSync10(authPath))
|
|
2911
|
+
return null;
|
|
2912
|
+
const a = JSON.parse(readFileSync7(authPath, "utf-8"));
|
|
2913
|
+
if (!a.token)
|
|
2914
|
+
return null;
|
|
2915
|
+
if (a.authenticated === false)
|
|
2916
|
+
return null;
|
|
2917
|
+
const u = a.user || {};
|
|
2918
|
+
return {
|
|
2919
|
+
token: a.token,
|
|
2920
|
+
portal: DEFAULT_PORTAL,
|
|
2921
|
+
profileId: activeId,
|
|
2922
|
+
user: {
|
|
2923
|
+
id: u.id || u.uuid || activeId,
|
|
2924
|
+
name: u.name || u.username || activeId,
|
|
2925
|
+
email: u.email || ""
|
|
2926
|
+
}
|
|
2927
|
+
};
|
|
2928
|
+
} catch {
|
|
2929
|
+
return null;
|
|
2896
2930
|
}
|
|
2897
|
-
return data;
|
|
2898
2931
|
}
|
|
2899
2932
|
function isAuthenticated() {
|
|
2900
2933
|
try {
|
|
@@ -10966,9 +10999,17 @@ function parseModelFile(content, fileName) {
|
|
|
10966
10999
|
const [, op, level] = accessMatch;
|
|
10967
11000
|
accessRules[op] = level;
|
|
10968
11001
|
}
|
|
11002
|
+
let scope;
|
|
11003
|
+
const scopeMatch = content.match(/scope\s*:\s*['"](app|project|org)['"]/);
|
|
11004
|
+
if (scopeMatch)
|
|
11005
|
+
scope = scopeMatch[1];
|
|
10969
11006
|
const result = { name: modelName, fields };
|
|
10970
|
-
if (Object.keys(accessRules).length > 0) {
|
|
10971
|
-
result.options = {
|
|
11007
|
+
if (Object.keys(accessRules).length > 0 || scope) {
|
|
11008
|
+
result.options = {};
|
|
11009
|
+
if (Object.keys(accessRules).length > 0)
|
|
11010
|
+
result.options.access = accessRules;
|
|
11011
|
+
if (scope)
|
|
11012
|
+
result.options.scope = scope;
|
|
10972
11013
|
}
|
|
10973
11014
|
return result;
|
|
10974
11015
|
}
|
|
@@ -11121,7 +11162,7 @@ function parseModelFields(content, fileName) {
|
|
|
11121
11162
|
// package.json
|
|
11122
11163
|
var package_default = {
|
|
11123
11164
|
name: "@construct-space/cli",
|
|
11124
|
-
version: "1.5.
|
|
11165
|
+
version: "1.5.1",
|
|
11125
11166
|
description: "Construct CLI \u2014 scaffold, build, develop, and publish spaces",
|
|
11126
11167
|
type: "module",
|
|
11127
11168
|
bin: {
|