@uipath/uipath-extensions-sdk 0.0.0-stage → 0.1.20
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 +3 -0
- package/README.md +254 -2
- package/THIRD-PARTY-NOTICES.txt +27 -0
- package/dist/adopt.d.ts +4 -0
- package/dist/adopt.js +549 -0
- package/dist/adopt.js.map +1 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +21 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.js +344 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/build-check.d.ts +34 -0
- package/dist/commands/build-check.js +121 -0
- package/dist/commands/build-check.js.map +1 -0
- package/dist/commands/new.d.ts +19 -0
- package/dist/commands/new.js +207 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/pack.d.ts +21 -0
- package/dist/commands/pack.js +189 -0
- package/dist/commands/pack.js.map +1 -0
- package/dist/commands/submit.d.ts +88 -0
- package/dist/commands/submit.js +561 -0
- package/dist/commands/submit.js.map +1 -0
- package/dist/commands/upload.d.ts +44 -0
- package/dist/commands/upload.js +306 -0
- package/dist/commands/upload.js.map +1 -0
- package/dist/commands/validate.d.ts +12 -0
- package/dist/commands/validate.js +16 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/defaultIcon.d.ts +2 -0
- package/dist/defaultIcon.js +225 -0
- package/dist/defaultIcon.js.map +1 -0
- package/dist/exists.d.ts +1 -0
- package/dist/exists.js +11 -0
- package/dist/exists.js.map +1 -0
- package/dist/fixture.d.ts +2 -0
- package/dist/fixture.js +6 -0
- package/dist/fixture.js.map +1 -0
- package/dist/github.d.ts +64 -0
- package/dist/github.js +277 -0
- package/dist/github.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/jobScaffold.d.ts +9 -0
- package/dist/jobScaffold.js +89 -0
- package/dist/jobScaffold.js.map +1 -0
- package/dist/lib.d.ts +73 -0
- package/dist/lib.js +372 -0
- package/dist/lib.js.map +1 -0
- package/dist/manifest.d.ts +1 -0
- package/dist/manifest.js +2 -0
- package/dist/manifest.js.map +1 -0
- package/dist/registrationFile.d.ts +9 -0
- package/dist/registrationFile.js +146 -0
- package/dist/registrationFile.js.map +1 -0
- package/dist/sourceWalk.d.ts +6 -0
- package/dist/sourceWalk.js +46 -0
- package/dist/sourceWalk.js.map +1 -0
- package/dist/uip.d.ts +10 -0
- package/dist/uip.js +35 -0
- package/dist/uip.js.map +1 -0
- package/package.json +41 -4
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { lstat, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { CONNECTION_HELPER_PATH, CONNECTION_HELPER_SOURCE, defaultExec, MANIFEST_FILE, MAX_LABEL_LENGTH, packageNameProblem, TemplateError, templateProblems, } from "@uipath/uipath-extensions-gates";
|
|
4
|
+
import { exists } from "../exists.js";
|
|
5
|
+
import { FIXTURE_PATH, starterFixtureText } from "../fixture.js";
|
|
6
|
+
import { makeJobOnly } from "../jobScaffold.js";
|
|
7
|
+
import { requireUip } from "../uip.js";
|
|
8
|
+
const NEW_TIMEOUT_MS = 600_000;
|
|
9
|
+
const FUNCTION_FILE = "functions/hello.ts";
|
|
10
|
+
const FIRST_VERSION = "0.1.0";
|
|
11
|
+
const MAX_OUTPUT_CHARS = 2000;
|
|
12
|
+
export const TYPES_NODE_PACKAGE = "@types/node";
|
|
13
|
+
export const TYPES_NODE_VERSION = "22.20.5";
|
|
14
|
+
export class NewError extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "NewError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const titleCase = (name) => name.replace(/(^|-)([a-z0-9])/g, (_, gap, c) => `${gap && " "}${c.toUpperCase()}`);
|
|
21
|
+
export const labelOf = (name) => titleCase(name).slice(0, MAX_LABEL_LENGTH).trimEnd();
|
|
22
|
+
const packageNameOf = (id) => `uipath-extensions.${id.replaceAll("/", ".")}`;
|
|
23
|
+
function starterTemplate(id) {
|
|
24
|
+
const [publisher = "", name = ""] = id.split("/");
|
|
25
|
+
return {
|
|
26
|
+
version: FIRST_VERSION,
|
|
27
|
+
license: "MIT",
|
|
28
|
+
author: {
|
|
29
|
+
name: titleCase(publisher),
|
|
30
|
+
url: `https://github.com/${publisher}`,
|
|
31
|
+
},
|
|
32
|
+
display: {
|
|
33
|
+
label: labelOf(name),
|
|
34
|
+
description: "Describe what this node does in one sentence.",
|
|
35
|
+
},
|
|
36
|
+
tags: [],
|
|
37
|
+
operations: [
|
|
38
|
+
{ name: "run", description: "Describe what this operation does." },
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const templateText = (template) => `${JSON.stringify(template, null, 2)}\n`;
|
|
43
|
+
const STARTER_FUNCTION = `import { defineFunction } from "@uipath/coded-functions-js-sdk";
|
|
44
|
+
|
|
45
|
+
export default defineFunction({
|
|
46
|
+
name: "hello",
|
|
47
|
+
description: "Returns a greeting message.",
|
|
48
|
+
input: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
name: { type: "string", description: "Describe this input." },
|
|
52
|
+
},
|
|
53
|
+
required: ["name"],
|
|
54
|
+
},
|
|
55
|
+
output: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
message: { type: "string", description: "Describe this output." },
|
|
59
|
+
},
|
|
60
|
+
required: ["message"],
|
|
61
|
+
additionalProperties: false,
|
|
62
|
+
},
|
|
63
|
+
handler: (input) => ({ message: \`Hello, \${input.name}!\` }),
|
|
64
|
+
});
|
|
65
|
+
`;
|
|
66
|
+
async function excludeTestsFromPackage(projectDir) {
|
|
67
|
+
const path = join(projectDir, "uipath.json");
|
|
68
|
+
const config = JSON.parse(await readFile(path, "utf8"));
|
|
69
|
+
const packOptions = (config.packOptions ?? {});
|
|
70
|
+
const excluded = (packOptions.directoriesExcluded ?? []);
|
|
71
|
+
if (excluded.includes("tests"))
|
|
72
|
+
return;
|
|
73
|
+
await writeFile(path, `${JSON.stringify({
|
|
74
|
+
...config,
|
|
75
|
+
packOptions: {
|
|
76
|
+
...packOptions,
|
|
77
|
+
directoriesExcluded: [...excluded, "tests"],
|
|
78
|
+
},
|
|
79
|
+
}, null, 2)}\n`);
|
|
80
|
+
}
|
|
81
|
+
async function alignPackageJson(projectDir, packageName) {
|
|
82
|
+
const path = join(projectDir, "package.json");
|
|
83
|
+
let parsed;
|
|
84
|
+
try {
|
|
85
|
+
parsed = JSON.parse(await readFile(path, "utf8"));
|
|
86
|
+
if (typeof parsed !== "object" ||
|
|
87
|
+
parsed === null ||
|
|
88
|
+
Array.isArray(parsed)) {
|
|
89
|
+
throw new Error("not an object");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
throw new NewError("the scaffold has no readable package.json object");
|
|
94
|
+
}
|
|
95
|
+
const { devDependencies, scripts } = parsed;
|
|
96
|
+
const { validate: _validate, ...otherScripts } = scripts ?? {};
|
|
97
|
+
await writeFile(path, `${JSON.stringify({
|
|
98
|
+
...parsed,
|
|
99
|
+
name: packageName,
|
|
100
|
+
version: FIRST_VERSION,
|
|
101
|
+
devDependencies: {
|
|
102
|
+
...devDependencies,
|
|
103
|
+
[TYPES_NODE_PACKAGE]: TYPES_NODE_VERSION,
|
|
104
|
+
},
|
|
105
|
+
scripts: { ...otherScripts, pack: "uip function pack" },
|
|
106
|
+
}, null, 2)}\n`);
|
|
107
|
+
}
|
|
108
|
+
async function createProject(exec, parentDir, name, packageName, template) {
|
|
109
|
+
const projectDir = join(parentDir, name);
|
|
110
|
+
const result = await exec("uip", ["function", "new", name, "--language", "ts"], { cwd: parentDir, timeout: NEW_TIMEOUT_MS });
|
|
111
|
+
if (result.timedOut)
|
|
112
|
+
throw new NewError("uip function new timed out");
|
|
113
|
+
if (result.code !== 0) {
|
|
114
|
+
const output = result.stderr || result.stdout;
|
|
115
|
+
throw new NewError(`uip function new exited with code ${result.code}: ${output.slice(-MAX_OUTPUT_CHARS)}`);
|
|
116
|
+
}
|
|
117
|
+
if (!(await exists(projectDir))) {
|
|
118
|
+
throw new NewError(`uip function new finished but ${projectDir} was not created`);
|
|
119
|
+
}
|
|
120
|
+
for (const required of ["functions/", "tsconfig.json", "uipath.json"]) {
|
|
121
|
+
if (!(await exists(join(projectDir, required)))) {
|
|
122
|
+
throw new NewError(`the scaffold has no ${required}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
await makeJobOnly(projectDir);
|
|
126
|
+
await alignPackageJson(projectDir, packageName);
|
|
127
|
+
await excludeTestsFromPackage(projectDir);
|
|
128
|
+
await rm(join(projectDir, ".env.example"), { force: true });
|
|
129
|
+
const templateFile = join(projectDir, MANIFEST_FILE);
|
|
130
|
+
if (await exists(templateFile)) {
|
|
131
|
+
throw new NewError(`${templateFile} already exists in the scaffold`);
|
|
132
|
+
}
|
|
133
|
+
const functionFile = join(projectDir, FUNCTION_FILE);
|
|
134
|
+
if (!(await exists(functionFile))) {
|
|
135
|
+
throw new NewError(`the scaffold has no ${FUNCTION_FILE}`);
|
|
136
|
+
}
|
|
137
|
+
const fixtureFile = join(projectDir, FIXTURE_PATH);
|
|
138
|
+
const fixtureDir = dirname(fixtureFile);
|
|
139
|
+
const occupant = await lstat(fixtureDir).catch(() => undefined);
|
|
140
|
+
if (occupant !== undefined && !occupant.isDirectory()) {
|
|
141
|
+
throw new NewError(`${fixtureDir} is not a directory in the scaffold`);
|
|
142
|
+
}
|
|
143
|
+
if (await exists(fixtureFile)) {
|
|
144
|
+
throw new NewError(`${fixtureFile} already exists in the scaffold`);
|
|
145
|
+
}
|
|
146
|
+
const operation = template.operations[0];
|
|
147
|
+
if (!operation)
|
|
148
|
+
throw new NewError("the starter template has no operation");
|
|
149
|
+
await writeFile(functionFile, STARTER_FUNCTION);
|
|
150
|
+
await writeFile(templateFile, templateText(template));
|
|
151
|
+
await mkdir(fixtureDir, { recursive: true });
|
|
152
|
+
await writeFile(fixtureFile, starterFixtureText(operation.name, { name: "World" }), { flag: "wx" });
|
|
153
|
+
const helperFile = join(projectDir, CONNECTION_HELPER_PATH);
|
|
154
|
+
await mkdir(dirname(helperFile), { recursive: true });
|
|
155
|
+
await writeFile(helperFile, CONNECTION_HELPER_SOURCE);
|
|
156
|
+
return { projectDir, templateFile };
|
|
157
|
+
}
|
|
158
|
+
async function installDependencies(exec, projectDir) {
|
|
159
|
+
const fail = (headline, detail = "") => new NewError(`${headline}. The project is kept in ${projectDir}. Fix the cause, then run npm install there.${detail && `\n${detail.trim().slice(-MAX_OUTPUT_CHARS)}`}`);
|
|
160
|
+
let result;
|
|
161
|
+
try {
|
|
162
|
+
result = await exec("npm", ["install", "--include=dev"], {
|
|
163
|
+
cwd: projectDir,
|
|
164
|
+
timeout: NEW_TIMEOUT_MS,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
throw fail(`npm could not run: ${error instanceof Error ? error.message : String(error)}`);
|
|
169
|
+
}
|
|
170
|
+
if (result.timedOut)
|
|
171
|
+
throw fail("npm install timed out");
|
|
172
|
+
if (result.code !== 0) {
|
|
173
|
+
throw fail(`npm install exited with code ${result.code}`, result.stderr || result.stdout);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export async function scaffold(options) {
|
|
177
|
+
const packageName = packageNameOf(options.id);
|
|
178
|
+
const nameProblem = packageNameProblem(packageName);
|
|
179
|
+
if (nameProblem) {
|
|
180
|
+
throw new NewError(`"${options.id}" is not a valid publisher/name. ${nameProblem}`);
|
|
181
|
+
}
|
|
182
|
+
const template = starterTemplate(options.id);
|
|
183
|
+
const problems = templateProblems(template);
|
|
184
|
+
if (problems.length > 0)
|
|
185
|
+
throw new TemplateError(problems);
|
|
186
|
+
const name = options.id.split("/")[1];
|
|
187
|
+
const projectDir = join(options.parentDir, name);
|
|
188
|
+
if (await exists(projectDir)) {
|
|
189
|
+
throw new NewError(`${projectDir} already exists`);
|
|
190
|
+
}
|
|
191
|
+
const exec = options.exec ?? defaultExec;
|
|
192
|
+
await requireUip(exec);
|
|
193
|
+
await mkdir(options.parentDir, { recursive: true });
|
|
194
|
+
let created;
|
|
195
|
+
try {
|
|
196
|
+
created = await createProject(exec, options.parentDir, name, packageName, template);
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
await rm(projectDir, { recursive: true, force: true });
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
const installed = !options.skipInstall;
|
|
203
|
+
if (installed)
|
|
204
|
+
await installDependencies(exec, created.projectDir);
|
|
205
|
+
return { ...created, installed };
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=new.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,WAAW,EAEX,aAAa,EACb,gBAAgB,EAEhB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAC3C,MAAM,aA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;IACD,MAAM,SAAS,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC;IACvC,IAAI,SAAS;QAAE,MAAM,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACnE,OAAO,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Exec } from "@uipath/uipath-extensions-gates";
|
|
2
|
+
export declare class PackError extends Error {
|
|
3
|
+
readonly needsAdopt: boolean;
|
|
4
|
+
constructor(message: string, needsAdopt?: boolean);
|
|
5
|
+
}
|
|
6
|
+
export interface PackOptions {
|
|
7
|
+
projectDir: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
exec?: Exec;
|
|
10
|
+
}
|
|
11
|
+
export interface PackResult {
|
|
12
|
+
version: string;
|
|
13
|
+
nupkgPath: string;
|
|
14
|
+
packageId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function readPackageInfo(projectDir: string): Promise<{
|
|
17
|
+
name: string;
|
|
18
|
+
version: string;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function withRegistrationExcluded<T>(projectDir: string, run: () => Promise<T>): Promise<T>;
|
|
21
|
+
export declare function pack(options: PackOptions): Promise<PackResult>;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { lstat, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { defaultExec, loadTemplate, packageNameProblem, } from "@uipath/uipath-extensions-gates";
|
|
4
|
+
import semver from "semver";
|
|
5
|
+
import { exists } from "../exists.js";
|
|
6
|
+
import { REGISTRATION_FILE } from "../registrationFile.js";
|
|
7
|
+
import { UipMissingError } from "../uip.js";
|
|
8
|
+
const PACK_TIMEOUT_MS = 600_000;
|
|
9
|
+
const NUPKG_DIRS = [".uipath", ""];
|
|
10
|
+
const MAX_OUTPUT_CHARS = 2000;
|
|
11
|
+
export class PackError extends Error {
|
|
12
|
+
needsAdopt;
|
|
13
|
+
constructor(message, needsAdopt = false) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.needsAdopt = needsAdopt;
|
|
16
|
+
this.name = "PackError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
function jsonLike(original, value) {
|
|
21
|
+
const indent = /^(\s+)"/m.exec(original)?.[1] ?? " ";
|
|
22
|
+
const newline = original.endsWith("\n") ? "\n" : "";
|
|
23
|
+
return `${JSON.stringify(value, null, indent)}${newline}`;
|
|
24
|
+
}
|
|
25
|
+
export async function readPackageInfo(projectDir) {
|
|
26
|
+
const path = join(projectDir, "package.json");
|
|
27
|
+
let text;
|
|
28
|
+
try {
|
|
29
|
+
text = await readFile(path, "utf8");
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
throw new PackError("package.json not found in the project");
|
|
33
|
+
}
|
|
34
|
+
let parsed;
|
|
35
|
+
try {
|
|
36
|
+
parsed = JSON.parse(text);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new PackError("package.json is not valid JSON");
|
|
40
|
+
}
|
|
41
|
+
if (!isRecord(parsed))
|
|
42
|
+
throw new PackError("package.json must be a JSON object");
|
|
43
|
+
const problem = packageNameProblem(parsed.name);
|
|
44
|
+
if (problem)
|
|
45
|
+
throw new PackError(problem, true);
|
|
46
|
+
if (typeof parsed.version !== "string") {
|
|
47
|
+
throw new PackError("package.json version must be a string");
|
|
48
|
+
}
|
|
49
|
+
return { name: parsed.name, version: parsed.version };
|
|
50
|
+
}
|
|
51
|
+
function tail(text) {
|
|
52
|
+
return text.length > MAX_OUTPUT_CHARS
|
|
53
|
+
? `...${text.slice(-MAX_OUTPUT_CHARS)}`
|
|
54
|
+
: text;
|
|
55
|
+
}
|
|
56
|
+
async function withPackageVersion(projectDir, version, run) {
|
|
57
|
+
const path = join(projectDir, "package.json");
|
|
58
|
+
const original = await readFile(path, "utf8");
|
|
59
|
+
const parsed = JSON.parse(original);
|
|
60
|
+
await writeFile(path, jsonLike(original, { ...parsed, version }));
|
|
61
|
+
try {
|
|
62
|
+
return await run();
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
await writeFile(path, original);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function restoreUipathJson(path, original, temporary, added) {
|
|
69
|
+
let current;
|
|
70
|
+
let parsed;
|
|
71
|
+
try {
|
|
72
|
+
current = await readFile(path, "utf8");
|
|
73
|
+
if (current === temporary)
|
|
74
|
+
return await writeFile(path, original);
|
|
75
|
+
parsed = JSON.parse(current);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return writeFile(path, original);
|
|
79
|
+
}
|
|
80
|
+
if (!isRecord(parsed) || !isRecord(parsed.packOptions))
|
|
81
|
+
return;
|
|
82
|
+
const options = { ...parsed.packOptions };
|
|
83
|
+
if (!Array.isArray(options.filesExcluded))
|
|
84
|
+
return;
|
|
85
|
+
const list = options.filesExcluded.filter((name) => name !== REGISTRATION_FILE);
|
|
86
|
+
if (added.list && list.length === 0)
|
|
87
|
+
delete options.filesExcluded;
|
|
88
|
+
else
|
|
89
|
+
options.filesExcluded = list;
|
|
90
|
+
const { packOptions: _, ...rest } = parsed;
|
|
91
|
+
const next = added.options && Object.keys(options).length === 0
|
|
92
|
+
? rest
|
|
93
|
+
: { ...rest, packOptions: options };
|
|
94
|
+
await writeFile(path, jsonLike(current, next));
|
|
95
|
+
}
|
|
96
|
+
export async function withRegistrationExcluded(projectDir, run) {
|
|
97
|
+
const path = join(projectDir, "uipath.json");
|
|
98
|
+
if (!(await exists(join(projectDir, REGISTRATION_FILE))))
|
|
99
|
+
return run();
|
|
100
|
+
const info = await lstat(path).catch(() => undefined);
|
|
101
|
+
if (info === undefined)
|
|
102
|
+
return run();
|
|
103
|
+
if (!info.isFile()) {
|
|
104
|
+
throw new PackError(`uipath.json is not a regular file, so pack cannot leave ${REGISTRATION_FILE} out of the package. Replace it with a regular file or remove ${REGISTRATION_FILE}`);
|
|
105
|
+
}
|
|
106
|
+
let original;
|
|
107
|
+
let parsed;
|
|
108
|
+
try {
|
|
109
|
+
original = await readFile(path, "utf8");
|
|
110
|
+
parsed = JSON.parse(original);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return run();
|
|
114
|
+
}
|
|
115
|
+
if (!isRecord(parsed))
|
|
116
|
+
return run();
|
|
117
|
+
const options = isRecord(parsed.packOptions) ? parsed.packOptions : {};
|
|
118
|
+
const excluded = options.filesExcluded ?? [];
|
|
119
|
+
if (!Array.isArray(excluded)) {
|
|
120
|
+
throw new PackError(`packOptions.filesExcluded in uipath.json is not a list, so pack cannot leave ${REGISTRATION_FILE} out of the package. Make it a list or remove ${REGISTRATION_FILE}`);
|
|
121
|
+
}
|
|
122
|
+
if (excluded.includes(REGISTRATION_FILE))
|
|
123
|
+
return run();
|
|
124
|
+
const next = {
|
|
125
|
+
...parsed,
|
|
126
|
+
packOptions: {
|
|
127
|
+
...options,
|
|
128
|
+
filesExcluded: [...excluded, REGISTRATION_FILE],
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
const temporary = jsonLike(original, next);
|
|
132
|
+
await writeFile(path, temporary);
|
|
133
|
+
try {
|
|
134
|
+
return await run();
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
await restoreUipathJson(path, original, temporary, {
|
|
138
|
+
options: !isRecord(parsed.packOptions),
|
|
139
|
+
list: options.filesExcluded === undefined,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export async function pack(options) {
|
|
144
|
+
const { projectDir } = options;
|
|
145
|
+
const exec = options.exec ?? defaultExec;
|
|
146
|
+
await loadTemplate(projectDir);
|
|
147
|
+
const { name: packageId, version: packageVersion } = await readPackageInfo(projectDir);
|
|
148
|
+
const version = options.version ?? packageVersion;
|
|
149
|
+
if (semver.valid(version) !== version) {
|
|
150
|
+
throw new PackError(`pack version ${JSON.stringify(version)} is not semver`);
|
|
151
|
+
}
|
|
152
|
+
const runPack = async () => {
|
|
153
|
+
try {
|
|
154
|
+
return await exec("uip", ["function", "pack"], {
|
|
155
|
+
cwd: projectDir,
|
|
156
|
+
timeout: PACK_TIMEOUT_MS,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (error.code === "ENOENT") {
|
|
161
|
+
throw new UipMissingError();
|
|
162
|
+
}
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const runExcludingRegistration = () => withRegistrationExcluded(projectDir, runPack);
|
|
167
|
+
const result = version === packageVersion
|
|
168
|
+
? await runExcludingRegistration()
|
|
169
|
+
: await withPackageVersion(projectDir, version, runExcludingRegistration);
|
|
170
|
+
if (result.timedOut)
|
|
171
|
+
throw new PackError("uip function pack timed out");
|
|
172
|
+
if (result.code !== 0) {
|
|
173
|
+
throw new PackError(`uip function pack exited with code ${result.code}: ${tail(result.stderr || result.stdout)}`);
|
|
174
|
+
}
|
|
175
|
+
const nupkgName = `${packageId}.${version}.nupkg`;
|
|
176
|
+
let nupkgPath;
|
|
177
|
+
for (const dir of NUPKG_DIRS) {
|
|
178
|
+
const candidate = join(projectDir, dir, nupkgName);
|
|
179
|
+
if (await exists(candidate)) {
|
|
180
|
+
nupkgPath = candidate;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (!nupkgPath) {
|
|
185
|
+
throw new PackError(`uip function pack finished but ${nupkgName} was not created in the project or in .uipath`);
|
|
186
|
+
}
|
|
187
|
+
return { version, nupkgPath, packageId };
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=pack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.js","sourceRoot":"","sources":["../../src/commands/pack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAA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,CAAC,CAAC;IAC9E,IAAI,MAAM,CAAC,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,6BAA6B,CAAC,CAAC;IACxE,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CACjB,sCAAsC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAC7F,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,GAAG,SAAS,IAAI,OAAO,QAAQ,CAAC;IAClD,IAAI,SAA6B,CAAC;IAClC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACnD,IAAI,MAAM,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,SAAS,GAAG,SAAS,CAAC;YACtB,MAAM;QACR,CAAC;IACH,CAAC;IACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,SAAS,CACjB,kCAAkC,SAAS,+CAA+C,CAC3F,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type Exec, type GateReport } from "@uipath/uipath-extensions-gates";
|
|
2
|
+
import { type GitHubClient, type PullReview } from "../github.js";
|
|
3
|
+
import { type ValidateOptions, type ValidateResult } from "./validate.js";
|
|
4
|
+
export declare const DEFAULT_INDEX_REPO = "UiPath/uipath-extensions";
|
|
5
|
+
export declare class SubmitError extends Error {
|
|
6
|
+
constructor(message: string, options?: ErrorOptions);
|
|
7
|
+
}
|
|
8
|
+
export declare class SecurityContactRequiredError extends SubmitError {
|
|
9
|
+
constructor(id: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class ChecksFailedError extends SubmitError {
|
|
12
|
+
readonly report: GateReport;
|
|
13
|
+
readonly others: string[];
|
|
14
|
+
constructor(report: GateReport, others?: string[]);
|
|
15
|
+
}
|
|
16
|
+
export declare class PrepareFailedError extends SubmitError {
|
|
17
|
+
readonly lines: string[];
|
|
18
|
+
constructor(lines: string[]);
|
|
19
|
+
}
|
|
20
|
+
export interface SubmitOptions {
|
|
21
|
+
projectDir: string;
|
|
22
|
+
github: GitHubClient;
|
|
23
|
+
securityContact?: string;
|
|
24
|
+
index?: string;
|
|
25
|
+
now?: () => Date;
|
|
26
|
+
exec?: Exec;
|
|
27
|
+
gateLibraryLine?: boolean;
|
|
28
|
+
generated?: {
|
|
29
|
+
field: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}[];
|
|
32
|
+
validate?: (options: ValidateOptions) => Promise<ValidateResult>;
|
|
33
|
+
}
|
|
34
|
+
export interface SubmitPlan {
|
|
35
|
+
index: string;
|
|
36
|
+
id: string;
|
|
37
|
+
version: string;
|
|
38
|
+
branch: string;
|
|
39
|
+
title: string;
|
|
40
|
+
action: "open" | "update";
|
|
41
|
+
pullUrl?: string;
|
|
42
|
+
registrationPath: string;
|
|
43
|
+
files: string[];
|
|
44
|
+
removed: string[];
|
|
45
|
+
skipped: string[];
|
|
46
|
+
moved: boolean;
|
|
47
|
+
checks: GateReport;
|
|
48
|
+
approvedBy: string[];
|
|
49
|
+
warnings: string[];
|
|
50
|
+
}
|
|
51
|
+
export interface SubmitResult extends SubmitPlan {
|
|
52
|
+
url: string;
|
|
53
|
+
labelled: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface SourceFile {
|
|
56
|
+
path: string;
|
|
57
|
+
content: Uint8Array;
|
|
58
|
+
}
|
|
59
|
+
export declare function collectFolder(root: string): Promise<{
|
|
60
|
+
files: SourceFile[];
|
|
61
|
+
skipped: string[];
|
|
62
|
+
problems: string[];
|
|
63
|
+
}>;
|
|
64
|
+
export declare function registrationText(input: {
|
|
65
|
+
id: string;
|
|
66
|
+
packageId: string;
|
|
67
|
+
version: string;
|
|
68
|
+
date: string;
|
|
69
|
+
securityContact?: string;
|
|
70
|
+
existing?: string;
|
|
71
|
+
}): string;
|
|
72
|
+
export declare function fillTemplate(template: string, fields: {
|
|
73
|
+
id: string;
|
|
74
|
+
version: string;
|
|
75
|
+
newNode: boolean;
|
|
76
|
+
}): string;
|
|
77
|
+
export declare function approvers(reviews: PullReview[]): string[];
|
|
78
|
+
export declare function withVersionLine(body: string, version: string): string | undefined;
|
|
79
|
+
export declare function submit(options: SubmitOptions & {
|
|
80
|
+
dryRun: true;
|
|
81
|
+
}): Promise<SubmitPlan>;
|
|
82
|
+
export declare function submit(options: SubmitOptions & {
|
|
83
|
+
dryRun?: false;
|
|
84
|
+
}): Promise<SubmitResult>;
|
|
85
|
+
export declare function submit(options: SubmitOptions & {
|
|
86
|
+
dryRun: boolean;
|
|
87
|
+
}): Promise<SubmitPlan | SubmitResult>;
|
|
88
|
+
export {};
|