@supernovaio/cli 0.9.28 → 0.9.30
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.
|
@@ -22,23 +22,32 @@ class SyncDesignTokens extends core_1.Command {
|
|
|
22
22
|
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
|
|
23
23
|
// MARK: - Command runtime
|
|
24
24
|
async run() {
|
|
25
|
+
var _a;
|
|
25
26
|
const { args, flags } = await this.parse(SyncDesignTokens);
|
|
26
27
|
// Get workspace -> design system –> version
|
|
27
28
|
let connected = await this.getWritableVersion(flags);
|
|
28
|
-
let dsTool = new supernova_sdk_1.SupernovaToolsDesignTokensPlugin(connected.version);
|
|
29
29
|
let dataLoader = new figma_tokens_data_loader_1.FigmaTokensDataLoader();
|
|
30
30
|
let configDefinition = dataLoader.loadConfigFromPath(flags.configFilePath);
|
|
31
31
|
let settings = configDefinition.settings;
|
|
32
32
|
if (args.dry) {
|
|
33
33
|
settings.dryRun = true;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const buildData = (payload) => ({
|
|
36
|
+
connection: { name: "CLI" },
|
|
37
|
+
...dataLoader.loadConfigFromPathAsIs(flags.configFilePath),
|
|
38
|
+
payload
|
|
39
|
+
});
|
|
40
|
+
if (!flags.tokenFilePath && !flags.tokenDirPath) {
|
|
41
|
+
throw new Error(`Either tokenFilePath or tokenDirPath must be provided`);
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
await
|
|
43
|
+
let tokenDefinition = flags.tokenDirPath
|
|
44
|
+
? await dataLoader.loadTokensFromDirectory(flags.tokenDirPath, flags.configFilePath)
|
|
45
|
+
: await dataLoader.loadTokensFromPath(flags.tokenFilePath);
|
|
46
|
+
const response = await connected.version.writer().writeTokenStudioData(buildData(tokenDefinition));
|
|
47
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.logs) && response.result.logs.length > 0) {
|
|
48
|
+
for (const log of response.result.logs) {
|
|
49
|
+
this.log(log);
|
|
50
|
+
}
|
|
42
51
|
}
|
|
43
52
|
this.log(`Tokens synchronized`);
|
|
44
53
|
}
|
|
@@ -50,8 +59,14 @@ class SyncDesignTokens extends core_1.Command {
|
|
|
50
59
|
throw new Error(`Design System ID must not be empty`);
|
|
51
60
|
}
|
|
52
61
|
// Create instance for prod / dev
|
|
53
|
-
const devAPIhost = "https://dev.api2.supernova.io/api";
|
|
54
|
-
|
|
62
|
+
const devAPIhost = "https://dev.api2.supernova.io/api/v2";
|
|
63
|
+
// After API V2 deploy to PROD, we need to use this URL.
|
|
64
|
+
// We won't get stats logs in CLI after it, just errors. Same way as TS Plugin.
|
|
65
|
+
const prodAPIV2host = "https://api.supernova.io/api/v2";
|
|
66
|
+
// We might need to ask people to update CLI before release, so after release all of them use BE call
|
|
67
|
+
// and do not push old tokens into new model.
|
|
68
|
+
// We will make a BE v1 bff/import endpoint to error with "Please, update CLI" message.
|
|
69
|
+
const apiUrl = flags.apiUrl && flags.apiUrl.length > 0 ? flags.apiUrl : flags.dev ? devAPIhost : prodAPIV2host;
|
|
55
70
|
let sdkInstance = new supernova_sdk_1.Supernova(flags.apiKey, apiUrl, null);
|
|
56
71
|
let designSystem = await sdkInstance.designSystem(flags.designSystemId);
|
|
57
72
|
if (!designSystem) {
|
|
@@ -97,7 +112,7 @@ SyncDesignTokens.flags = {
|
|
|
97
112
|
hidden: false,
|
|
98
113
|
default: false,
|
|
99
114
|
}),
|
|
100
|
-
apiUrl: core_1.Flags.string({ description: "API url to use for accessing Supernova instance, would ignore defaults", hidden: true })
|
|
115
|
+
apiUrl: core_1.Flags.string({ description: "API url to use for accessing Supernova instance, would ignore defaults", hidden: true })
|
|
101
116
|
};
|
|
102
117
|
// Required and optional attributes
|
|
103
118
|
SyncDesignTokens.args = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DTPluginToSupernovaSettings, DTPluginToSupernovaMapPack } from "@supernovaio/supernova-sdk";
|
|
1
|
+
import { DTPluginToSupernovaSettings, DTPluginToSupernovaMapPack, DTPluginToSupernovaMappingFile } from "@supernovaio/supernova-sdk";
|
|
2
2
|
export declare class FigmaTokensDataLoader {
|
|
3
3
|
/** Load token definitions from path */
|
|
4
4
|
loadTokensFromPath(pathToFile: string): Promise<object>;
|
|
@@ -10,6 +10,7 @@ export declare class FigmaTokensDataLoader {
|
|
|
10
10
|
mapping: DTPluginToSupernovaMapPack;
|
|
11
11
|
settings: DTPluginToSupernovaSettings;
|
|
12
12
|
};
|
|
13
|
+
loadConfigFromPathAsIs(pathToFile: string): DTPluginToSupernovaMappingFile;
|
|
13
14
|
private weakValidateMapping;
|
|
14
15
|
private processFileToMapping;
|
|
15
16
|
private parseDefinition;
|
|
@@ -80,14 +80,23 @@ class FigmaTokensDataLoader {
|
|
|
80
80
|
return jsonFilePath.substring(loadedDirectory.length + 1, jsonFilePath.length - 5);
|
|
81
81
|
}
|
|
82
82
|
loadConfigFromPath(pathToFile) {
|
|
83
|
+
try {
|
|
84
|
+
let parsedDefinition = this.loadConfigFromPathAsIs(pathToFile);
|
|
85
|
+
this.weakValidateMapping(parsedDefinition);
|
|
86
|
+
return this.processFileToMapping(parsedDefinition);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
throw new Error('Unable to load JSON definition file: ' + error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
loadConfigFromPathAsIs(pathToFile) {
|
|
83
93
|
try {
|
|
84
94
|
if (!(fs.existsSync(pathToFile) && fs.lstatSync(pathToFile).isFile())) {
|
|
85
95
|
throw new Error(`Provided configuration file directory ${pathToFile} is not a file or doesn't exist`);
|
|
86
96
|
}
|
|
87
97
|
let definition = fs.readFileSync(pathToFile, 'utf8');
|
|
88
98
|
let parsedDefinition = this.parseDefinition(definition);
|
|
89
|
-
|
|
90
|
-
return this.processFileToMapping(parsedDefinition);
|
|
99
|
+
return parsedDefinition;
|
|
91
100
|
}
|
|
92
101
|
catch (error) {
|
|
93
102
|
throw new Error('Unable to load JSON definition file: ' + error);
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.9.
|
|
1
|
+
{"version":"0.9.30","commands":{"describe-design-system":{"id":"describe-design-system","description":"Describe structure of single design system by provided ID","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli describe-design-system --apiKey=\"{xxx-xxx-xxx}\" --designSystemId=\"{1234}\""],"flags":{"apiKey":{"name":"apiKey","type":"option","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"designSystemId":{"name":"designSystemId","type":"option","description":"Design System to describe structure of","required":true,"multiple":false},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false}},"args":[],"_globalFlags":{}},"describe-workspaces":{"id":"describe-workspaces","description":"Describe structure of all workspaces and design systems available under those workspaces available for specified API key","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli describe-workspaces --apiKey=\"{xxx-xxx-xxx}\""],"flags":{"apiKey":{"name":"apiKey","type":"option","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false}},"args":[],"_globalFlags":{}},"publish-documentation":{"id":"publish-documentation","description":"Publish latest version of the documentation","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli publish-documentation --apiKey=\"{xxx-xxx-xxx}\" --designSystemId=\"{1234}\""],"flags":{"apiKey":{"name":"apiKey","type":"option","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"designSystemId":{"name":"designSystemId","type":"option","description":"Design System to publish the documentation","required":true,"multiple":false},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false},"environment":{"name":"environment","type":"option","description":"Environment to use for publishing: Live or Preview","required":false,"multiple":false,"default":"Live"}},"args":[],"_globalFlags":{}},"sync-tokens":{"id":"sync-tokens","description":"Synchronize tokens from Figma Tokens plugin to Supernova workspaces","strict":true,"pluginName":"@supernovaio/cli","pluginAlias":"@supernovaio/cli","pluginType":"core","aliases":[],"examples":["$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenFilePath \"/path/to/tokens.json\" --configFilePath \"/path/to/config.json\"","$ @supernovaio/cli sync-tokens --apiKey=\"{xxx-xxx-xxx}\" --designSystemId={1234} --tokenDirPath \"/path/to/tokens/\" --configFilePath \"/path/to/config.json\""],"flags":{"apiKey":{"name":"apiKey","type":"option","description":"API key to use for accessing Supernova instance","required":true,"multiple":false},"designSystemId":{"name":"designSystemId","type":"option","description":"Design System to synchronize contents with","required":true,"multiple":false},"tokenFilePath":{"name":"tokenFilePath","type":"option","description":"Path to JSON file containing token definitions","multiple":false},"tokenDirPath":{"name":"tokenDirPath","type":"option","description":"Path to directory of JSON files containing token definitions","multiple":false},"configFilePath":{"name":"configFilePath","type":"option","description":"Path to configuration JSON file","required":true,"multiple":false,"exclusive":[]},"dev":{"name":"dev","type":"boolean","description":"When enabled, CLI will target dev server","hidden":true,"allowNo":false},"dry":{"name":"dry","type":"boolean","description":"When enabled, dry run will be performed and tokens won't write into workspace. This settings overrides settings inside configuration files.","hidden":false,"allowNo":false},"apiUrl":{"name":"apiUrl","type":"option","description":"API url to use for accessing Supernova instance, would ignore defaults","hidden":true,"multiple":false}},"args":[],"_globalFlags":{}}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supernovaio/cli",
|
|
3
3
|
"description": "Supernova.io Command Line Interface",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.30",
|
|
5
5
|
"author": "Supernova.io",
|
|
6
6
|
"homepage": "https://supernova.io/",
|
|
7
7
|
"keywords": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@oclif/core": "^1",
|
|
26
26
|
"@oclif/plugin-help": "^5",
|
|
27
27
|
"@oclif/plugin-plugins": "^2.0.1",
|
|
28
|
-
"@supernovaio/supernova-sdk": "1.
|
|
28
|
+
"@supernovaio/supernova-sdk": "1.9.5",
|
|
29
29
|
"chalk": "^5.0.1",
|
|
30
30
|
"node-fetch": "^3.2.4",
|
|
31
31
|
"dotenv": "^16.0.0"
|