@uniformdev/cli 17.7.1-alpha.34 → 18.0.1-alpha.3
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/LICENSE.txt +1 -1
- package/dist/chunk-IRPO3X2Q.mjs +1576 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1736 -7
- package/dist/index.mjs +174 -2
- package/dist/sync/index.d.ts +12 -12
- package/dist/sync/index.js +2008 -9
- package/dist/sync/index.mjs +420 -4
- package/package.json +7 -6
- package/dist/chunk-LPA4W6MO.mjs +0 -6
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,175 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
__require,
|
|
4
|
+
__toESM,
|
|
5
|
+
require_source
|
|
6
|
+
} from "./chunk-IRPO3X2Q.mjs";
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
import yargs3 from "yargs";
|
|
10
|
+
|
|
11
|
+
// src/commands/optimize.ts
|
|
12
|
+
import yargs2 from "yargs";
|
|
13
|
+
|
|
14
|
+
// src/commands/optimize/manifest.ts
|
|
15
|
+
import yargs from "yargs";
|
|
16
|
+
|
|
17
|
+
// src/commands/optimize/manifest/download.ts
|
|
18
|
+
var import_chalk = __toESM(require_source());
|
|
19
|
+
import { writeFile } from "fs";
|
|
20
|
+
import fetch from "isomorphic-unfetch";
|
|
21
|
+
import { exit } from "process";
|
|
22
|
+
|
|
23
|
+
// src/constants.ts
|
|
24
|
+
var UniformBaseUrl = "https://uniform.app";
|
|
25
|
+
|
|
26
|
+
// src/commands/optimize/manifest/download.ts
|
|
27
|
+
var module = {
|
|
28
|
+
command: "download [output]",
|
|
29
|
+
describe: "Download intent manifest",
|
|
30
|
+
builder: (yargs4) => {
|
|
31
|
+
var _a;
|
|
32
|
+
return yargs4.option("apiKey", {
|
|
33
|
+
alias: "k",
|
|
34
|
+
demandOption: true,
|
|
35
|
+
string: true,
|
|
36
|
+
default: process.env.UNIFORM_API_KEY,
|
|
37
|
+
describe: "Uniform API key to use. Defaults to UNIFORM_API_KEY env if set."
|
|
38
|
+
}).option("project", {
|
|
39
|
+
describe: "Uniform project ID. Defaults to UOPT_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
|
|
40
|
+
default: (_a = process.env.UOPT_CLI_PROJECT_ID) != null ? _a : process.env.UNIFORM_PROJECT_ID,
|
|
41
|
+
type: "string",
|
|
42
|
+
alias: ["p"]
|
|
43
|
+
}).option("preview", {
|
|
44
|
+
describe: "If set, fetches the unpublished preview manifest (assuming your API key has permission)",
|
|
45
|
+
default: false,
|
|
46
|
+
type: "boolean",
|
|
47
|
+
alias: ["d"]
|
|
48
|
+
}).option("output", {
|
|
49
|
+
string: true,
|
|
50
|
+
alias: "o",
|
|
51
|
+
default: process.env.UNIFORM_MANIFEST_PATH,
|
|
52
|
+
describe: "Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set."
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
handler: async ({ apiKey, output, project, preview }) => {
|
|
56
|
+
const isLegacyApiKey = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i.test(
|
|
57
|
+
apiKey
|
|
58
|
+
);
|
|
59
|
+
if (isLegacyApiKey) {
|
|
60
|
+
console.error(
|
|
61
|
+
import_chalk.default.yellow(
|
|
62
|
+
"WARNING: you appear to be using a deprecated type of API key. Keys like this will stop working soon; please create new keys on uniform.app."
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
} else if (!project) {
|
|
66
|
+
console.error(import_chalk.default.red("You must specify the project ID"));
|
|
67
|
+
exit(1);
|
|
68
|
+
}
|
|
69
|
+
const baseUrl = resolveBaseUrl();
|
|
70
|
+
const qs = new URLSearchParams();
|
|
71
|
+
if (project) {
|
|
72
|
+
qs.set("projectId", project);
|
|
73
|
+
}
|
|
74
|
+
if (preview) {
|
|
75
|
+
qs.set("preview", "true");
|
|
76
|
+
}
|
|
77
|
+
const manifestUrl = `${baseUrl}api/v1/manifest?${qs.toString()}`;
|
|
78
|
+
let fetchResponse = void 0;
|
|
79
|
+
try {
|
|
80
|
+
fetchResponse = await fetch(manifestUrl, {
|
|
81
|
+
headers: {
|
|
82
|
+
"x-api-key": apiKey
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (!fetchResponse.ok) {
|
|
86
|
+
if (fetchResponse.status === 403) {
|
|
87
|
+
throw `The API key ${apiKey} had no published data. This means it is either incorrectly entered, or intents have not been published since creating the API key.`;
|
|
88
|
+
}
|
|
89
|
+
throw `${fetchResponse.status} ${fetchResponse.statusText}, content ${await fetchResponse.text()}`;
|
|
90
|
+
}
|
|
91
|
+
} catch (e) {
|
|
92
|
+
console.error(import_chalk.default.red(`\u26A0 Error fetching intent manifest ${manifestUrl}`));
|
|
93
|
+
console.error(import_chalk.default.gray(` \u2757 ${e}`));
|
|
94
|
+
exit(1);
|
|
95
|
+
}
|
|
96
|
+
let json;
|
|
97
|
+
try {
|
|
98
|
+
json = await fetchResponse.json();
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.error(import_chalk.default.red(import_chalk.default.red(`\u26A0 Error parsing intent manifest ${manifestUrl}`)));
|
|
101
|
+
console.error(import_chalk.default.gray(` \u2757 ${e}`));
|
|
102
|
+
console.error(`Response: ${await fetchResponse.text()}`);
|
|
103
|
+
exit(1);
|
|
104
|
+
}
|
|
105
|
+
const text = JSON.stringify(json, null, 2);
|
|
106
|
+
if (output) {
|
|
107
|
+
writeFile(output, text, (error) => {
|
|
108
|
+
if (error) {
|
|
109
|
+
console.error(`Error writing file to ${output}
|
|
110
|
+
`, error);
|
|
111
|
+
exit(1);
|
|
112
|
+
}
|
|
113
|
+
console.log(import_chalk.default.green(`\u2705 ${output} has been updated from ${manifestUrl}`));
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
console.log(text);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
var resolveBaseUrl = () => {
|
|
121
|
+
let baseUrl = process.env.UNIFORM_CLI_BASE_URL || UniformBaseUrl;
|
|
122
|
+
if (!baseUrl.endsWith("/")) {
|
|
123
|
+
baseUrl += "/";
|
|
124
|
+
}
|
|
125
|
+
return baseUrl;
|
|
126
|
+
};
|
|
127
|
+
var download_default = module;
|
|
128
|
+
|
|
129
|
+
// src/commands/optimize/manifest.ts
|
|
130
|
+
var module2 = {
|
|
131
|
+
command: "manifest <command>",
|
|
132
|
+
describe: "Intent manifest commands",
|
|
133
|
+
builder: () => {
|
|
134
|
+
return yargs.command(download_default);
|
|
135
|
+
},
|
|
136
|
+
handler: () => {
|
|
137
|
+
return yargs.showHelp();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var manifest_default = module2;
|
|
141
|
+
|
|
142
|
+
// src/commands/optimize.ts
|
|
143
|
+
var command = {
|
|
144
|
+
command: "optimize <command>",
|
|
145
|
+
aliases: ["opt"],
|
|
146
|
+
describe: "Uniform Optimize commands",
|
|
147
|
+
builder: () => {
|
|
148
|
+
return yargs2.command(manifest_default);
|
|
149
|
+
},
|
|
150
|
+
handler: () => {
|
|
151
|
+
return yargs2.showHelp();
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var optimize_default = command;
|
|
155
|
+
|
|
156
|
+
// src/index.ts
|
|
157
|
+
__require("dotenv").config();
|
|
158
|
+
var plugins = [
|
|
159
|
+
"@uniformdev/canvas/cli",
|
|
160
|
+
"@uniformdev/context/cli",
|
|
161
|
+
"@uniformdev/project-map/cli",
|
|
162
|
+
"@uniformdev/uniform-new"
|
|
163
|
+
];
|
|
164
|
+
var yarggery = yargs3.scriptName("uniform");
|
|
165
|
+
plugins.flatMap((plugin) => {
|
|
166
|
+
try {
|
|
167
|
+
const commands = __require(plugin).uniformCLI.commands;
|
|
168
|
+
const commandsToAdd = Array.isArray(commands) ? commands : [];
|
|
169
|
+
commandsToAdd.forEach((command2) => {
|
|
170
|
+
yarggery = yarggery.command(command2);
|
|
171
|
+
});
|
|
172
|
+
} catch (e) {
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
yarggery.command(optimize_default).demandCommand(1, "").strict().help().argv;
|
package/dist/sync/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Change } from 'diff';
|
|
2
2
|
import { Argv } from 'yargs';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type SyncEngineLogOptions = {
|
|
5
5
|
id: string;
|
|
6
6
|
providerId: string;
|
|
7
7
|
displayName: string;
|
|
@@ -9,7 +9,7 @@ declare type SyncEngineLogOptions = {
|
|
|
9
9
|
whatIf: boolean;
|
|
10
10
|
diff: Change[];
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type SyncEngineObject<TObject> = {
|
|
13
13
|
/** Unique ID that is identical across all providers */
|
|
14
14
|
id: string;
|
|
15
15
|
/** Provider specific ID. Value is provided to deleteObject() function (always the provider ID from the same provider that issued it). */
|
|
@@ -19,7 +19,7 @@ declare type SyncEngineObject<TObject> = {
|
|
|
19
19
|
/** The object being synced. */
|
|
20
20
|
object: TObject;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
type SyncEngineDataSource<TObject> = {
|
|
23
23
|
/** The objects to sync. */
|
|
24
24
|
objects: AsyncIterable<SyncEngineObject<TObject>>;
|
|
25
25
|
/**
|
|
@@ -39,7 +39,7 @@ declare type SyncEngineDataSource<TObject> = {
|
|
|
39
39
|
*/
|
|
40
40
|
onSyncComplete?: (isTarget: boolean) => Promise<void>;
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
type SyncEngineOptions<TObject> = {
|
|
43
43
|
source: SyncEngineDataSource<TObject>;
|
|
44
44
|
target: SyncEngineDataSource<TObject>;
|
|
45
45
|
compareContents?: (source: SyncEngineObject<TObject>, target: SyncEngineObject<TObject>) => boolean;
|
|
@@ -55,7 +55,7 @@ declare class SyncEngineError<TObject> extends Error {
|
|
|
55
55
|
constructor(innerError: unknown, sourceObject: SyncEngineObject<TObject>);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
type CreateArraySyncEngineDataSourceOptions<TObject> = {
|
|
59
59
|
objects: Array<TObject>;
|
|
60
60
|
selectIdentifier: (object: TObject) => string;
|
|
61
61
|
selectDisplayName?: (object: TObject) => string;
|
|
@@ -65,7 +65,7 @@ declare function createArraySyncEngineDataSource<TObject>({ objects, selectIdent
|
|
|
65
65
|
extractCurrent: () => Array<TObject>;
|
|
66
66
|
}>;
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
type CreateFileSyncEngineDataSourceOptions<TObject> = {
|
|
69
69
|
directory: string;
|
|
70
70
|
selectIdentifier: (object: TObject) => string;
|
|
71
71
|
selectDisplayName?: (object: TObject) => string;
|
|
@@ -74,36 +74,36 @@ declare type CreateFileSyncEngineDataSourceOptions<TObject> = {
|
|
|
74
74
|
};
|
|
75
75
|
declare function createFileSyncEngineDataSource<TObject>({ directory, format, selectIdentifier, selectDisplayName, selectFilename, }: CreateFileSyncEngineDataSourceOptions<TObject>): Promise<SyncEngineDataSource<TObject>>;
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
type UniformPackage = {
|
|
78
78
|
[key: string]: unknown;
|
|
79
79
|
};
|
|
80
80
|
declare function readUniformPackage(filename: string, assertExists: boolean): UniformPackage;
|
|
81
81
|
declare function writeUniformPackage(filename: string, packageContents: UniformPackage): void;
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
type DiffMode = 'off' | 'on' | 'update';
|
|
84
84
|
declare function createSyncEngineConsoleLogger(options?: {
|
|
85
85
|
diffMode?: DiffMode;
|
|
86
86
|
indent?: string;
|
|
87
87
|
prefix?: string;
|
|
88
88
|
}): ({ action, displayName, whatIf, diff }: SyncEngineLogOptions) => void;
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
type ApiArgs = {
|
|
91
91
|
apiKey: string;
|
|
92
92
|
apiHost: string;
|
|
93
93
|
proxy?: string;
|
|
94
94
|
};
|
|
95
95
|
declare function withApiOptions<T>(yargs: Argv<T>): Argv<T>;
|
|
96
96
|
declare function nodeFetchProxy(proxy: string | undefined): typeof fetch;
|
|
97
|
-
|
|
97
|
+
type ProjectArgs = {
|
|
98
98
|
project: string;
|
|
99
99
|
};
|
|
100
100
|
declare function withProjectOptions<T>(yargs: Argv<T>): Argv<T>;
|
|
101
|
-
|
|
101
|
+
type FormatArgs = {
|
|
102
102
|
format: 'json' | 'yaml';
|
|
103
103
|
filename?: string;
|
|
104
104
|
};
|
|
105
105
|
declare function withFormatOptions<T>(yargs: Argv<T>): Argv<T>;
|
|
106
|
-
|
|
106
|
+
type DiffArgs = {
|
|
107
107
|
diff: DiffMode;
|
|
108
108
|
};
|
|
109
109
|
declare function withDiffOptions<T>(yargs: Argv<T>): Argv<T>;
|