dataverse-utils 2.0.9 → 2.0.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/lib/assemblyDeploy.js +11 -18
- package/lib/auth.js +9 -13
- package/lib/cachePlugin.js +16 -23
- package/lib/dataverse-utils.js +12 -17
- package/lib/dataverse.service.js +10 -16
- package/lib/deploy.js +18 -24
- package/lib/generate.js +24 -32
- package/lib/models/pluginAssembly.js +20 -27
- package/lib/models/pluginImage.js +8 -12
- package/lib/models/pluginStep.js +18 -23
- package/lib/models/pluginType.js +10 -14
- package/lib/models/webResource.js +20 -27
- package/lib/webResourceDeploy.js +11 -18
- package/license +21 -0
- package/package.json +3 -2
package/lib/assemblyDeploy.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.deployAssembly = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const pluginAssembly_1 = require("./models/pluginAssembly");
|
|
10
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
11
|
-
async function deployAssembly(creds, apiConfig) {
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { deploy } from './models/pluginAssembly';
|
|
4
|
+
import { logger } from 'just-scripts-utils';
|
|
5
|
+
export async function deployAssembly(creds, apiConfig) {
|
|
12
6
|
const currentPath = '.';
|
|
13
|
-
const configFile =
|
|
7
|
+
const configFile = fs.readFileSync(path.resolve(currentPath, 'dataverse.config.json'), 'utf8');
|
|
14
8
|
if (configFile == null) {
|
|
15
|
-
|
|
9
|
+
logger.warn('unable to find dataverse.config.json file');
|
|
16
10
|
return;
|
|
17
11
|
}
|
|
18
12
|
const config = JSON.parse(configFile);
|
|
19
|
-
|
|
13
|
+
logger.info('deploy assembly');
|
|
20
14
|
try {
|
|
21
|
-
await
|
|
15
|
+
await deploy(config, apiConfig, creds.solution);
|
|
22
16
|
}
|
|
23
17
|
catch (error) {
|
|
24
|
-
|
|
18
|
+
logger.error(error.message);
|
|
25
19
|
return;
|
|
26
20
|
}
|
|
27
|
-
|
|
21
|
+
logger.info(`deployed assembly ${config.name}\r\n`);
|
|
28
22
|
}
|
|
29
|
-
exports.deployAssembly = deployAssembly;
|
package/lib/auth.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const cachePlugin_1 = require("./cachePlugin");
|
|
5
|
-
const msal_node_1 = require("@azure/msal-node");
|
|
6
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
1
|
+
import { cachePlugin } from './cachePlugin';
|
|
2
|
+
import { PublicClientApplication } from '@azure/msal-node';
|
|
3
|
+
import { logger } from 'just-scripts-utils';
|
|
7
4
|
const clientId = '51f81489-12ee-4a9e-aaae-a2591f45987d';
|
|
8
|
-
const getAccessToken = async (tenant, url) => {
|
|
5
|
+
export const getAccessToken = async (tenant, url) => {
|
|
9
6
|
const config = {
|
|
10
7
|
auth: {
|
|
11
8
|
clientId: clientId,
|
|
12
9
|
authority: `https://login.microsoftonline.com/${tenant}/`
|
|
13
10
|
},
|
|
14
11
|
cache: {
|
|
15
|
-
cachePlugin:
|
|
12
|
+
cachePlugin: cachePlugin(url.replace('https://', '').split('.')[0])
|
|
16
13
|
}
|
|
17
14
|
};
|
|
18
|
-
const pca = new
|
|
15
|
+
const pca = new PublicClientApplication(config);
|
|
19
16
|
const cache = pca.getTokenCache();
|
|
20
|
-
const accounts = await
|
|
17
|
+
const accounts = await cache?.getAllAccounts().catch(ex => {
|
|
21
18
|
throw new Error(ex.message);
|
|
22
|
-
})
|
|
19
|
+
});
|
|
23
20
|
// Try to get token silently
|
|
24
21
|
if (accounts.length > 0) {
|
|
25
22
|
const silentToken = await pca.acquireTokenSilent({
|
|
@@ -35,10 +32,9 @@ const getAccessToken = async (tenant, url) => {
|
|
|
35
32
|
// Acquire token by device code
|
|
36
33
|
const token = await pca.acquireTokenByDeviceCode({
|
|
37
34
|
scopes: [`${url}/.default`],
|
|
38
|
-
deviceCodeCallback: (response) =>
|
|
35
|
+
deviceCodeCallback: (response) => logger.info(response.message)
|
|
39
36
|
}).catch(ex => {
|
|
40
37
|
throw new Error(ex.message);
|
|
41
38
|
});
|
|
42
39
|
return token;
|
|
43
40
|
};
|
|
44
|
-
exports.getAccessToken = getAccessToken;
|
package/lib/cachePlugin.js
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.cachePlugin = void 0;
|
|
7
|
-
const os_1 = __importDefault(require("os"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const cryptr_1 = __importDefault(require("cryptr"));
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import Cryptr from 'cryptr';
|
|
11
5
|
const encrypt = (text) => {
|
|
12
|
-
const user =
|
|
13
|
-
const cryptr = new
|
|
6
|
+
const user = os.userInfo().username;
|
|
7
|
+
const cryptr = new Cryptr(user);
|
|
14
8
|
const encrypted = cryptr.encrypt(text);
|
|
15
9
|
return encrypted;
|
|
16
10
|
};
|
|
17
11
|
const decrypt = (text) => {
|
|
18
|
-
const user =
|
|
19
|
-
const cryptr = new
|
|
12
|
+
const user = os.userInfo().username;
|
|
13
|
+
const cryptr = new Cryptr(user);
|
|
20
14
|
const decrypted = cryptr.decrypt(text);
|
|
21
15
|
return decrypted;
|
|
22
16
|
};
|
|
23
|
-
function cachePlugin(org) {
|
|
17
|
+
export function cachePlugin(org) {
|
|
24
18
|
const getCachePath = () => {
|
|
25
|
-
if (!
|
|
26
|
-
|
|
19
|
+
if (!fs.existsSync(path.join(os.homedir(), './.dataverse-utils/'))) {
|
|
20
|
+
fs.mkdirSync(path.join(os.homedir(), './.dataverse-utils/'));
|
|
27
21
|
}
|
|
28
|
-
return
|
|
22
|
+
return path.join(os.homedir(), `./.dataverse-utils/${org}.json`);
|
|
29
23
|
};
|
|
30
24
|
const cacheLocation = getCachePath();
|
|
31
25
|
const beforeCacheAccess = (tokenCacheContext) => {
|
|
32
26
|
return new Promise((resolve, reject) => {
|
|
33
|
-
if (
|
|
34
|
-
|
|
27
|
+
if (fs.existsSync(cacheLocation)) {
|
|
28
|
+
fs.readFile(cacheLocation, 'utf-8', (err, data) => {
|
|
35
29
|
if (err) {
|
|
36
30
|
reject();
|
|
37
31
|
}
|
|
@@ -44,7 +38,7 @@ function cachePlugin(org) {
|
|
|
44
38
|
}
|
|
45
39
|
else {
|
|
46
40
|
const encrypted = encrypt(tokenCacheContext.tokenCache.serialize());
|
|
47
|
-
|
|
41
|
+
fs.writeFile(cacheLocation, encrypted, (err) => {
|
|
48
42
|
if (err) {
|
|
49
43
|
reject();
|
|
50
44
|
}
|
|
@@ -59,7 +53,7 @@ function cachePlugin(org) {
|
|
|
59
53
|
return new Promise((resolve, reject) => {
|
|
60
54
|
if (tokenCacheContext.cacheHasChanged) {
|
|
61
55
|
const encrypted = encrypt(tokenCacheContext.tokenCache.serialize());
|
|
62
|
-
|
|
56
|
+
fs.writeFile(cacheLocation, encrypted, (err) => {
|
|
63
57
|
if (err) {
|
|
64
58
|
reject(err);
|
|
65
59
|
}
|
|
@@ -76,4 +70,3 @@ function cachePlugin(org) {
|
|
|
76
70
|
afterCacheAccess
|
|
77
71
|
};
|
|
78
72
|
}
|
|
79
|
-
exports.cachePlugin = cachePlugin;
|
package/lib/dataverse-utils.js
CHANGED
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const deploy_1 = __importDefault(require("./deploy"));
|
|
9
|
-
const generate_1 = __importDefault(require("./generate"));
|
|
10
|
-
commander_1.program
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import deploy from './deploy';
|
|
4
|
+
import generate from './generate';
|
|
5
|
+
program
|
|
11
6
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
12
7
|
.version(require('../package').version)
|
|
13
8
|
.usage('<command> [options]');
|
|
14
9
|
// Deploy command
|
|
15
|
-
|
|
10
|
+
program
|
|
16
11
|
.command('deploy')
|
|
17
12
|
.description('Deploy file(s) to dataverse (webresource, plugin, workflow)')
|
|
18
13
|
.argument('[type]', 'Type of project to deploy')
|
|
19
14
|
.argument('[files]', 'Comma separate list of files to deploy')
|
|
20
15
|
.action((type, files) => {
|
|
21
|
-
(
|
|
16
|
+
deploy(type, files);
|
|
22
17
|
});
|
|
23
18
|
// Generate command
|
|
24
|
-
|
|
19
|
+
program
|
|
25
20
|
.command('generate')
|
|
26
21
|
.description('Generate early-bound TypeScript file for specified table')
|
|
27
22
|
.argument('[table]', 'Table to generate')
|
|
28
23
|
.action((table) => {
|
|
29
|
-
(
|
|
24
|
+
generate(table);
|
|
30
25
|
});
|
|
31
26
|
// Show help on unknown command
|
|
32
|
-
|
|
27
|
+
program
|
|
33
28
|
.arguments('<command>')
|
|
34
29
|
.action((cmd) => {
|
|
35
|
-
|
|
30
|
+
program.outputHelp();
|
|
36
31
|
console.log();
|
|
37
32
|
console.log(`Unknown command ${cmd}.`);
|
|
38
33
|
console.log();
|
|
39
34
|
});
|
|
40
|
-
|
|
35
|
+
program.parse(process.argv);
|
|
41
36
|
if (!process.argv.slice(2).length) {
|
|
42
|
-
|
|
37
|
+
program.outputHelp();
|
|
43
38
|
}
|
package/lib/dataverse.service.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getTableMetadata = exports.publish = exports.addToSolution = exports.ComponentType = void 0;
|
|
4
|
-
const node_1 = require("dataverse-webapi/lib/node");
|
|
5
|
-
var ComponentType;
|
|
1
|
+
import { retrieveMultiple, unboundAction } from 'dataverse-webapi/lib/node';
|
|
2
|
+
export var ComponentType;
|
|
6
3
|
(function (ComponentType) {
|
|
7
4
|
ComponentType[ComponentType["WebResource"] = 61] = "WebResource";
|
|
8
5
|
ComponentType[ComponentType["PluginType"] = 90] = "PluginType";
|
|
9
6
|
ComponentType[ComponentType["PluginAssembly"] = 91] = "PluginAssembly";
|
|
10
7
|
ComponentType[ComponentType["SDKMessageProcessingStep"] = 92] = "SDKMessageProcessingStep";
|
|
11
8
|
ComponentType[ComponentType["SDKMessageProcessingStepImage"] = 93] = "SDKMessageProcessingStepImage";
|
|
12
|
-
})(ComponentType
|
|
13
|
-
async function addToSolution(id, solution, type, apiConfig) {
|
|
9
|
+
})(ComponentType || (ComponentType = {}));
|
|
10
|
+
export async function addToSolution(id, solution, type, apiConfig) {
|
|
14
11
|
const data = {
|
|
15
12
|
ComponentId: id,
|
|
16
13
|
ComponentType: type,
|
|
@@ -18,22 +15,20 @@ async function addToSolution(id, solution, type, apiConfig) {
|
|
|
18
15
|
AddRequiredComponents: false,
|
|
19
16
|
IncludedComponentSettingsValues: null
|
|
20
17
|
};
|
|
21
|
-
await
|
|
18
|
+
await unboundAction(apiConfig, 'AddSolutionComponent', data);
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
async function publish(publishXml, apiConfig) {
|
|
20
|
+
export async function publish(publishXml, apiConfig) {
|
|
25
21
|
const data = {
|
|
26
22
|
ParameterXml: `<importexportxml><webresources>${publishXml}</webresources></importexportxml>`
|
|
27
23
|
};
|
|
28
|
-
await
|
|
24
|
+
await unboundAction(apiConfig, 'PublishXml', data);
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
async function getTableMetadata(table, apiConfig) {
|
|
26
|
+
export async function getTableMetadata(table, apiConfig) {
|
|
32
27
|
const options = [
|
|
33
28
|
'?$select=DisplayName,LogicalName,EntitySetName,SchemaName',
|
|
34
29
|
'&$expand=Attributes($select=LogicalName,SchemaName)'
|
|
35
30
|
].join('');
|
|
36
|
-
const metadata = await
|
|
31
|
+
const metadata = await retrieveMultiple(apiConfig, `EntityDefinitions(LogicalName='${table}')`, options);
|
|
37
32
|
if (metadata == null) {
|
|
38
33
|
throw Error(`Table ${table} not found in metadata cache`);
|
|
39
34
|
}
|
|
@@ -41,7 +36,7 @@ async function getTableMetadata(table, apiConfig) {
|
|
|
41
36
|
'?$select=attributevalue,value,attributename',
|
|
42
37
|
`&$filter=objecttypecode eq '${table}'`
|
|
43
38
|
].join('');
|
|
44
|
-
const choiceMetadata = await
|
|
39
|
+
const choiceMetadata = await retrieveMultiple(apiConfig, 'stringmaps', choiceOptions);
|
|
45
40
|
const tableMetadata = {
|
|
46
41
|
logicalName: metadata.LogicalName,
|
|
47
42
|
schemaName: metadata.SchemaName,
|
|
@@ -65,4 +60,3 @@ async function getTableMetadata(table, apiConfig) {
|
|
|
65
60
|
});
|
|
66
61
|
return tableMetadata;
|
|
67
62
|
}
|
|
68
|
-
exports.getTableMetadata = getTableMetadata;
|
package/lib/deploy.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const assemblyDeploy_1 = require("./assemblyDeploy");
|
|
11
|
-
const webResourceDeploy_1 = require("./webResourceDeploy");
|
|
12
|
-
const node_1 = require("dataverse-webapi/lib/node");
|
|
13
|
-
const auth_1 = require("./auth");
|
|
14
|
-
async function deploy(type, files) {
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { logger } from 'just-scripts-utils';
|
|
5
|
+
import { deployAssembly } from './assemblyDeploy';
|
|
6
|
+
import { deployWebResource } from './webResourceDeploy';
|
|
7
|
+
import { WebApiConfig } from 'dataverse-webapi/lib/node';
|
|
8
|
+
import { getAccessToken } from './auth';
|
|
9
|
+
export default async function deploy(type, files) {
|
|
15
10
|
if (!type || (type !== 'webresource' && type !== 'assembly')) {
|
|
16
11
|
const invalid = type !== undefined && type !== 'webresource' && type !== 'assembly';
|
|
17
12
|
const invalidMessage = invalid ? `${type} is not a valid project type.` : '';
|
|
18
|
-
const { typePrompt } = await (
|
|
13
|
+
const { typePrompt } = await prompts({
|
|
19
14
|
type: 'select',
|
|
20
15
|
name: 'typePrompt',
|
|
21
16
|
message: `${invalidMessage} select project type to deploy`,
|
|
@@ -27,34 +22,33 @@ async function deploy(type, files) {
|
|
|
27
22
|
type = typePrompt;
|
|
28
23
|
}
|
|
29
24
|
const currentPath = '.';
|
|
30
|
-
const credsFile =
|
|
25
|
+
const credsFile = fs.readFileSync(path.resolve(currentPath, 'dataverse.config.json'), 'utf8');
|
|
31
26
|
if (credsFile == null) {
|
|
32
|
-
|
|
27
|
+
logger.warn('unable to find dataverse.config.json file');
|
|
33
28
|
return;
|
|
34
29
|
}
|
|
35
30
|
const creds = JSON.parse(credsFile).connection;
|
|
36
31
|
let token = null;
|
|
37
32
|
try {
|
|
38
|
-
token = await
|
|
33
|
+
token = await getAccessToken(creds.tenant, creds.server);
|
|
39
34
|
}
|
|
40
35
|
catch (error) {
|
|
41
|
-
|
|
36
|
+
logger.error(`failed to acquire access token: ${error.message}`);
|
|
42
37
|
return;
|
|
43
38
|
}
|
|
44
39
|
if (token == null || token.accessToken == null) {
|
|
45
|
-
|
|
40
|
+
logger.error('failed to acquire access token');
|
|
46
41
|
return;
|
|
47
42
|
}
|
|
48
|
-
const apiConfig = new
|
|
43
|
+
const apiConfig = new WebApiConfig('8.2', token.accessToken, creds.server);
|
|
49
44
|
switch (type) {
|
|
50
45
|
case 'webresource':
|
|
51
|
-
await
|
|
46
|
+
await deployWebResource(creds, apiConfig, files);
|
|
52
47
|
break;
|
|
53
48
|
case 'assembly':
|
|
54
|
-
await
|
|
49
|
+
await deployAssembly(creds, apiConfig);
|
|
55
50
|
break;
|
|
56
51
|
default:
|
|
57
52
|
break;
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
|
-
exports.default = deploy;
|
package/lib/generate.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
10
|
-
const dataverse_service_1 = require("./dataverse.service");
|
|
11
|
-
const node_1 = require("dataverse-webapi/lib/node");
|
|
12
|
-
const auth_1 = require("./auth");
|
|
13
|
-
async function generate(table) {
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { logger } from 'just-scripts-utils';
|
|
5
|
+
import { getTableMetadata } from './dataverse.service';
|
|
6
|
+
import { WebApiConfig } from 'dataverse-webapi/lib/node';
|
|
7
|
+
import { getAccessToken } from './auth';
|
|
8
|
+
export default async function generate(table) {
|
|
14
9
|
while (!table) {
|
|
15
|
-
const { tablePrompt } = await (
|
|
10
|
+
const { tablePrompt } = await prompts({
|
|
16
11
|
type: 'text',
|
|
17
12
|
name: 'tablePrompt',
|
|
18
13
|
message: `enter table to generate`
|
|
@@ -20,32 +15,32 @@ async function generate(table) {
|
|
|
20
15
|
table = tablePrompt;
|
|
21
16
|
}
|
|
22
17
|
const currentPath = '.';
|
|
23
|
-
const credsFile =
|
|
18
|
+
const credsFile = fs.readFileSync(path.resolve(currentPath, 'dataverse.config.json'), 'utf8');
|
|
24
19
|
if (credsFile == null) {
|
|
25
|
-
|
|
20
|
+
logger.warn('unable to find dataverse.config.json file');
|
|
26
21
|
return;
|
|
27
22
|
}
|
|
28
23
|
const creds = JSON.parse(credsFile).connection;
|
|
29
24
|
let token = null;
|
|
30
25
|
try {
|
|
31
|
-
token = await
|
|
26
|
+
token = await getAccessToken(creds.tenant, creds.server);
|
|
32
27
|
}
|
|
33
28
|
catch (error) {
|
|
34
|
-
|
|
29
|
+
logger.error(`failed to acquire access token: ${error.message}`);
|
|
35
30
|
return;
|
|
36
31
|
}
|
|
37
32
|
if (token == null || token.accessToken == null) {
|
|
38
|
-
|
|
33
|
+
logger.error('failed to acquire access token');
|
|
39
34
|
return;
|
|
40
35
|
}
|
|
41
|
-
const apiConfig = new
|
|
36
|
+
const apiConfig = new WebApiConfig('8.2', token.accessToken, creds.server);
|
|
42
37
|
let metadata = {};
|
|
43
|
-
|
|
38
|
+
logger.info('Retrieve table metadata');
|
|
44
39
|
try {
|
|
45
|
-
metadata = await
|
|
40
|
+
metadata = await getTableMetadata(table, apiConfig);
|
|
46
41
|
}
|
|
47
42
|
catch (error) {
|
|
48
|
-
|
|
43
|
+
logger.error(error.message);
|
|
49
44
|
return;
|
|
50
45
|
}
|
|
51
46
|
// Build code file from metadata
|
|
@@ -69,19 +64,17 @@ async function generate(table) {
|
|
|
69
64
|
'\r\n',
|
|
70
65
|
'\r\n',
|
|
71
66
|
metadata.choices.map(c => {
|
|
72
|
-
var _a, _b;
|
|
73
67
|
const field = metadata.fields.find(f => f.logicalName === c.column);
|
|
74
|
-
return ` ${
|
|
68
|
+
return ` ${field?.schemaName ?? c.column} = ${metadata.schemaName}_${field?.schemaName ?? c.column};`;
|
|
75
69
|
}).join('\r\n'),
|
|
76
70
|
'\r\n',
|
|
77
71
|
'}',
|
|
78
72
|
'\r\n',
|
|
79
73
|
'\r\n',
|
|
80
74
|
metadata.choices.map(c => {
|
|
81
|
-
var _a;
|
|
82
75
|
const field = metadata.fields.find(f => f.logicalName === c.column);
|
|
83
76
|
return [
|
|
84
|
-
`export enum ${metadata.schemaName}_${
|
|
77
|
+
`export enum ${metadata.schemaName}_${field?.schemaName ?? c.column} {`,
|
|
85
78
|
'\r\n',
|
|
86
79
|
c.options.map(x => ` '${x.text.replace(`'`, `\\'`)}' = ${x.value}`).join(',\r\n'),
|
|
87
80
|
'\r\n',
|
|
@@ -92,10 +85,9 @@ async function generate(table) {
|
|
|
92
85
|
'\r\n',
|
|
93
86
|
`export default new ${metadata.schemaName}();`
|
|
94
87
|
].join('');
|
|
95
|
-
if (!
|
|
96
|
-
|
|
88
|
+
if (!fs.existsSync(path.resolve(currentPath, 'src', 'scripts', 'models'))) {
|
|
89
|
+
fs.mkdirSync(path.resolve(currentPath, 'src', 'scripts', 'models'));
|
|
97
90
|
}
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
fs.writeFileSync(path.resolve(currentPath, 'src', 'scripts', 'models', `${metadata.schemaName}.ts`), codeFile);
|
|
92
|
+
logger.info(`Table metadata output to models/${metadata.schemaName}.ts`);
|
|
100
93
|
}
|
|
101
|
-
exports.default = generate;
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const node_1 = require("dataverse-webapi/lib/node");
|
|
10
|
-
const pluginType_1 = require("./pluginType");
|
|
11
|
-
const dataverse_service_1 = require("../dataverse.service");
|
|
12
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
13
|
-
async function deploy(config, apiConfig, solution) {
|
|
14
|
-
const files = glob_1.default.sync(`**/${config.name}.dll`);
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import glob from 'glob';
|
|
3
|
+
import { retrieveMultiple, createWithReturnData, update } from 'dataverse-webapi/lib/node';
|
|
4
|
+
import { deployType } from './pluginType';
|
|
5
|
+
import { addToSolution, ComponentType } from '../dataverse.service';
|
|
6
|
+
import { logger } from 'just-scripts-utils';
|
|
7
|
+
export async function deploy(config, apiConfig, solution) {
|
|
8
|
+
const files = glob.sync(`**/${config.name}.dll`);
|
|
15
9
|
if (files.length === 0) {
|
|
16
|
-
|
|
10
|
+
logger.error(`assembly ${config.name}.dll not found`);
|
|
17
11
|
return;
|
|
18
12
|
}
|
|
19
|
-
const content =
|
|
13
|
+
const content = fs.readFileSync(files[0]).toString('base64');
|
|
20
14
|
let assemblyId = '';
|
|
21
15
|
try {
|
|
22
16
|
assemblyId = await retrieveAssembly(config.name, apiConfig);
|
|
23
17
|
}
|
|
24
18
|
catch (error) {
|
|
25
|
-
|
|
19
|
+
logger.error(`failed to retrieve assembly ${config.name}: ${error.message}`);
|
|
26
20
|
return;
|
|
27
21
|
}
|
|
28
22
|
if (assemblyId != '') {
|
|
@@ -42,10 +36,10 @@ async function deploy(config, apiConfig, solution) {
|
|
|
42
36
|
}
|
|
43
37
|
if (solution != undefined) {
|
|
44
38
|
try {
|
|
45
|
-
await
|
|
39
|
+
await addToSolution(assemblyId, solution, ComponentType.PluginAssembly, apiConfig);
|
|
46
40
|
}
|
|
47
41
|
catch (error) {
|
|
48
|
-
|
|
42
|
+
logger.error(`failed to add to solution: ${error.message}`);
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
45
|
}
|
|
@@ -53,24 +47,23 @@ async function deploy(config, apiConfig, solution) {
|
|
|
53
47
|
try {
|
|
54
48
|
const promises = config.types.map(async (type) => {
|
|
55
49
|
type['pluginassemblyid@odata.bind'] = `/pluginassemblies(${assemblyId})`;
|
|
56
|
-
await
|
|
50
|
+
await deployType(type, apiConfig, solution);
|
|
57
51
|
});
|
|
58
52
|
await Promise.all(promises);
|
|
59
53
|
}
|
|
60
54
|
catch (error) {
|
|
61
|
-
|
|
55
|
+
logger.error(error.message);
|
|
62
56
|
return;
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
exports.deploy = deploy;
|
|
67
60
|
async function retrieveAssembly(name, apiConfig) {
|
|
68
61
|
const options = `$select=pluginassemblyid&$filter=name eq '${name}'`;
|
|
69
|
-
const result = await
|
|
62
|
+
const result = await retrieveMultiple(apiConfig, 'pluginassemblies', options);
|
|
70
63
|
return result.value.length > 0 ? result.value[0].pluginassemblyid : '';
|
|
71
64
|
}
|
|
72
65
|
async function createAssembly(config, content, apiConfig) {
|
|
73
|
-
|
|
66
|
+
logger.info(`create assembly ${config.name}`);
|
|
74
67
|
const assembly = {
|
|
75
68
|
name: config.name,
|
|
76
69
|
content: content,
|
|
@@ -80,17 +73,17 @@ async function createAssembly(config, content, apiConfig) {
|
|
|
80
73
|
sourcetype: 0,
|
|
81
74
|
culture: ''
|
|
82
75
|
};
|
|
83
|
-
const result = await
|
|
76
|
+
const result = await createWithReturnData(apiConfig, 'pluginassemblies', assembly, '$select=pluginassemblyid');
|
|
84
77
|
if (result.error) {
|
|
85
78
|
throw new Error(result.error.message);
|
|
86
79
|
}
|
|
87
80
|
return result.pluginassemblyid;
|
|
88
81
|
}
|
|
89
82
|
async function updateAssembly(id, config, content, apiConfig) {
|
|
90
|
-
|
|
83
|
+
logger.info(`update assembly ${config.name}`);
|
|
91
84
|
const assembly = {
|
|
92
85
|
content: content,
|
|
93
86
|
version: config.version
|
|
94
87
|
};
|
|
95
|
-
return
|
|
88
|
+
return update(apiConfig, 'pluginassemblies', id, assembly);
|
|
96
89
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
5
|
-
const node_1 = require("dataverse-webapi/lib/node");
|
|
6
|
-
async function deployImage(stepId, image, message, apiConfig) {
|
|
1
|
+
import { logger } from 'just-scripts-utils';
|
|
2
|
+
import { retrieveMultiple, createWithReturnData, update } from 'dataverse-webapi/lib/node';
|
|
3
|
+
export async function deployImage(stepId, image, message, apiConfig) {
|
|
7
4
|
image['sdkmessageprocessingstepid@odata.bind'] = `/sdkmessageprocessingsteps(${stepId})`;
|
|
8
5
|
switch (message) {
|
|
9
6
|
case 'Create':
|
|
@@ -41,21 +38,20 @@ async function deployImage(stepId, image, message, apiConfig) {
|
|
|
41
38
|
}
|
|
42
39
|
return imageId;
|
|
43
40
|
}
|
|
44
|
-
exports.deployImage = deployImage;
|
|
45
41
|
async function retrieveImage(stepId, image, apiConfig) {
|
|
46
42
|
const options = `$select=sdkmessageprocessingstepimageid&$filter=name eq '${image.name}' and _sdkmessageprocessingstepid_value eq ${stepId}`;
|
|
47
|
-
const result = await
|
|
43
|
+
const result = await retrieveMultiple(apiConfig, 'sdkmessageprocessingstepimages', options);
|
|
48
44
|
return result.value.length > 0 ? result.value[0].sdkmessageprocessingstepimageid : '';
|
|
49
45
|
}
|
|
50
46
|
async function createImage(image, apiConfig) {
|
|
51
|
-
|
|
52
|
-
const result = await
|
|
47
|
+
logger.info(`create plugin image ${image.name}`);
|
|
48
|
+
const result = await createWithReturnData(apiConfig, 'sdkmessageprocessingstepimages', image, '$select=sdkmessageprocessingstepimageid');
|
|
53
49
|
if (result.error) {
|
|
54
50
|
throw new Error(result.error.message);
|
|
55
51
|
}
|
|
56
52
|
return result.sdkmessageprocessingstepimageid;
|
|
57
53
|
}
|
|
58
54
|
async function updateImage(id, image, apiConfig) {
|
|
59
|
-
|
|
60
|
-
return
|
|
55
|
+
logger.info(`update plugin image ${image.name}`);
|
|
56
|
+
return update(apiConfig, 'sdkmessageprocessingstepimages', id, image);
|
|
61
57
|
}
|
package/lib/models/pluginStep.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
7
|
-
const pluginImage_1 = require("./pluginImage");
|
|
8
|
-
async function deployStep(step, apiConfig, solution) {
|
|
9
|
-
var _a, _b;
|
|
1
|
+
import { retrieveMultiple, createWithReturnData, update } from 'dataverse-webapi/lib/node';
|
|
2
|
+
import { addToSolution, ComponentType } from '../dataverse.service';
|
|
3
|
+
import { logger } from 'just-scripts-utils';
|
|
4
|
+
import { deployImage } from './pluginImage';
|
|
5
|
+
export async function deployStep(step, apiConfig, solution) {
|
|
10
6
|
let stepId = await retrieveStep(step.name, apiConfig);
|
|
11
|
-
const messageId = await getSdkMessageId(
|
|
7
|
+
const messageId = await getSdkMessageId(step.message ?? '', apiConfig);
|
|
12
8
|
if (messageId == '') {
|
|
13
|
-
|
|
9
|
+
logger.error(`sdk message ${step.message} not found`);
|
|
14
10
|
return;
|
|
15
11
|
}
|
|
16
|
-
const filterId = await getSdkMessageFilterId(messageId,
|
|
12
|
+
const filterId = await getSdkMessageFilterId(messageId, step.entity ?? '', apiConfig);
|
|
17
13
|
if (filterId == '') {
|
|
18
|
-
|
|
14
|
+
logger.error(`sdk message ${step.message} for entity ${step.entity} not found`);
|
|
19
15
|
return;
|
|
20
16
|
}
|
|
21
17
|
step['sdkmessagefilterid@odata.bind'] = `/sdkmessagefilters(${filterId})`;
|
|
@@ -45,7 +41,7 @@ async function deployStep(step, apiConfig, solution) {
|
|
|
45
41
|
}
|
|
46
42
|
if (solution != undefined) {
|
|
47
43
|
try {
|
|
48
|
-
await
|
|
44
|
+
await addToSolution(stepId, solution, ComponentType.SDKMessageProcessingStep, apiConfig);
|
|
49
45
|
}
|
|
50
46
|
catch (error) {
|
|
51
47
|
throw new Error(`failed to add to solution: ${error.message}`);
|
|
@@ -54,7 +50,7 @@ async function deployStep(step, apiConfig, solution) {
|
|
|
54
50
|
}
|
|
55
51
|
if (images && images.length > 0) {
|
|
56
52
|
try {
|
|
57
|
-
const promises = images.map(image =>
|
|
53
|
+
const promises = images.map(image => deployImage(stepId, image, message, apiConfig));
|
|
58
54
|
await Promise.all(promises);
|
|
59
55
|
}
|
|
60
56
|
catch (error) {
|
|
@@ -63,10 +59,9 @@ async function deployStep(step, apiConfig, solution) {
|
|
|
63
59
|
}
|
|
64
60
|
return stepId;
|
|
65
61
|
}
|
|
66
|
-
exports.deployStep = deployStep;
|
|
67
62
|
async function retrieveStep(name, apiConfig) {
|
|
68
63
|
const options = `$select=sdkmessageprocessingstepid&$filter=name eq '${name}'`;
|
|
69
|
-
const result = await
|
|
64
|
+
const result = await retrieveMultiple(apiConfig, 'sdkmessageprocessingsteps', options);
|
|
70
65
|
return result.value.length > 0 ? result.value[0].sdkmessageprocessingstepid : '';
|
|
71
66
|
}
|
|
72
67
|
async function getSdkMessageFilterId(messageId, entityName, apiConfig) {
|
|
@@ -74,7 +69,7 @@ async function getSdkMessageFilterId(messageId, entityName, apiConfig) {
|
|
|
74
69
|
`?$filter=primaryobjecttypecode eq '${entityName}' and _sdkmessageid_value eq ${messageId}`,
|
|
75
70
|
'&$select=sdkmessagefilterid'
|
|
76
71
|
].join('');
|
|
77
|
-
const message = await
|
|
72
|
+
const message = await retrieveMultiple(apiConfig, 'sdkmessagefilters', options);
|
|
78
73
|
return message.value.length > 0 ? message.value[0].sdkmessagefilterid : '';
|
|
79
74
|
}
|
|
80
75
|
async function getSdkMessageId(name, apiConfig) {
|
|
@@ -82,18 +77,18 @@ async function getSdkMessageId(name, apiConfig) {
|
|
|
82
77
|
`?$filter=name eq '${name}'`,
|
|
83
78
|
'&$select=sdkmessageid'
|
|
84
79
|
].join('');
|
|
85
|
-
const message = await
|
|
80
|
+
const message = await retrieveMultiple(apiConfig, 'sdkmessages', options);
|
|
86
81
|
return message.value.length > 0 ? message.value[0].sdkmessageid : '';
|
|
87
82
|
}
|
|
88
83
|
async function createStep(step, apiConfig) {
|
|
89
|
-
|
|
90
|
-
const result = await
|
|
84
|
+
logger.info(`create plugin step ${step.name}`);
|
|
85
|
+
const result = await createWithReturnData(apiConfig, 'sdkmessageprocessingsteps', step, '$select=sdkmessageprocessingstepid');
|
|
91
86
|
if (result.error) {
|
|
92
87
|
throw new Error(result.error.message);
|
|
93
88
|
}
|
|
94
89
|
return result.sdkmessageprocessingstepid;
|
|
95
90
|
}
|
|
96
91
|
async function updateStep(id, step, apiConfig) {
|
|
97
|
-
|
|
98
|
-
return
|
|
92
|
+
logger.info(`update plugin step ${step.name}`);
|
|
93
|
+
return update(apiConfig, 'sdkmessageprocessingsteps', id, step);
|
|
99
94
|
}
|
package/lib/models/pluginType.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const pluginStep_1 = require("./pluginStep");
|
|
6
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
7
|
-
async function deployType(type, apiConfig, solution) {
|
|
1
|
+
import { retrieveMultiple, createWithReturnData, update } from 'dataverse-webapi/lib/node';
|
|
2
|
+
import { deployStep } from './pluginStep';
|
|
3
|
+
import { logger } from 'just-scripts-utils';
|
|
4
|
+
export async function deployType(type, apiConfig, solution) {
|
|
8
5
|
let typeId = await retrieveType(type.typename, apiConfig);
|
|
9
6
|
const record = {
|
|
10
7
|
name: type.name,
|
|
@@ -33,7 +30,7 @@ async function deployType(type, apiConfig, solution) {
|
|
|
33
30
|
if (type.steps) {
|
|
34
31
|
const promises = type.steps.map(async (step) => {
|
|
35
32
|
step['plugintypeid@odata.bind'] = `/plugintypes(${typeId})`;
|
|
36
|
-
await
|
|
33
|
+
await deployStep(step, apiConfig, solution);
|
|
37
34
|
});
|
|
38
35
|
await Promise.all(promises);
|
|
39
36
|
}
|
|
@@ -43,21 +40,20 @@ async function deployType(type, apiConfig, solution) {
|
|
|
43
40
|
}
|
|
44
41
|
return typeId;
|
|
45
42
|
}
|
|
46
|
-
exports.deployType = deployType;
|
|
47
43
|
async function retrieveType(name, apiConfig) {
|
|
48
44
|
const options = `$select=plugintypeid&$filter=typename eq '${name}'`;
|
|
49
|
-
const result = await
|
|
45
|
+
const result = await retrieveMultiple(apiConfig, 'plugintypes', options);
|
|
50
46
|
return result.value.length > 0 ? result.value[0].plugintypeid : '';
|
|
51
47
|
}
|
|
52
48
|
async function createType(type, apiConfig) {
|
|
53
|
-
|
|
54
|
-
const result = await
|
|
49
|
+
logger.info(`create assembly type ${type.name}`);
|
|
50
|
+
const result = await createWithReturnData(apiConfig, 'plugintypes', type, '$select=plugintypeid');
|
|
55
51
|
if (result.error) {
|
|
56
52
|
throw new Error(result.error.message);
|
|
57
53
|
}
|
|
58
54
|
return result.plugintypeid;
|
|
59
55
|
}
|
|
60
56
|
async function updateType(id, type, apiConfig) {
|
|
61
|
-
|
|
62
|
-
return
|
|
57
|
+
logger.info(`update assembly type ${type.name}`);
|
|
58
|
+
return update(apiConfig, 'plugintypes', id, type);
|
|
63
59
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.deploy = void 0;
|
|
7
|
-
const dataverse_service_1 = require("../dataverse.service");
|
|
8
|
-
const node_1 = require("dataverse-webapi/lib/node");
|
|
9
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
1
|
+
import { addToSolution, ComponentType, publish } from '../dataverse.service';
|
|
2
|
+
import { retrieveMultiple, createWithReturnData, update } from 'dataverse-webapi/lib/node';
|
|
3
|
+
import { logger } from 'just-scripts-utils';
|
|
4
|
+
import fs from 'fs';
|
|
11
5
|
function getWebResourceType(type) {
|
|
12
6
|
switch (type) {
|
|
13
7
|
case 'HTML':
|
|
@@ -38,16 +32,16 @@ function getWebResourceType(type) {
|
|
|
38
32
|
return 0;
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
|
-
async function deploy(webResources, apiConfig, solution, files) {
|
|
35
|
+
export async function deploy(webResources, apiConfig, solution, files) {
|
|
42
36
|
const publishXml = [];
|
|
43
37
|
let resources = webResources;
|
|
44
38
|
// Use list of files if provided
|
|
45
39
|
if (files) {
|
|
46
40
|
resources = [];
|
|
47
41
|
for (const file of files.split(',')) {
|
|
48
|
-
const resource = webResources.filter(r =>
|
|
42
|
+
const resource = webResources.filter(r => r.path?.endsWith(file));
|
|
49
43
|
if (resource.length === 0) {
|
|
50
|
-
|
|
44
|
+
logger.error(`web resource ${file} not found in dataverse.config.json`);
|
|
51
45
|
continue;
|
|
52
46
|
}
|
|
53
47
|
resources.push(resource[0]);
|
|
@@ -59,10 +53,10 @@ async function deploy(webResources, apiConfig, solution, files) {
|
|
|
59
53
|
resourceId = await retrieveResource(resource.name, apiConfig);
|
|
60
54
|
}
|
|
61
55
|
catch (error) {
|
|
62
|
-
|
|
56
|
+
logger.error(`failed to retrieve resource ${resource.name}: ${error.message}`);
|
|
63
57
|
return;
|
|
64
58
|
}
|
|
65
|
-
const fileContent =
|
|
59
|
+
const fileContent = fs.readFileSync(resource.path, 'utf8');
|
|
66
60
|
const content = Buffer.from(fileContent).toString('base64');
|
|
67
61
|
if (resourceId != '') {
|
|
68
62
|
try {
|
|
@@ -70,7 +64,7 @@ async function deploy(webResources, apiConfig, solution, files) {
|
|
|
70
64
|
publishXml.push(updated);
|
|
71
65
|
}
|
|
72
66
|
catch (error) {
|
|
73
|
-
|
|
67
|
+
logger.error(`failed to update resource: ${error.message}`);
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
70
|
else {
|
|
@@ -78,14 +72,14 @@ async function deploy(webResources, apiConfig, solution, files) {
|
|
|
78
72
|
resourceId = await createResource(resource, content, apiConfig);
|
|
79
73
|
}
|
|
80
74
|
catch (error) {
|
|
81
|
-
|
|
75
|
+
logger.error(`failed to create resource: ${error.message}`);
|
|
82
76
|
}
|
|
83
77
|
if (solution != undefined) {
|
|
84
78
|
try {
|
|
85
|
-
await
|
|
79
|
+
await addToSolution(resourceId, solution, ComponentType.WebResource, apiConfig);
|
|
86
80
|
}
|
|
87
81
|
catch (error) {
|
|
88
|
-
|
|
82
|
+
logger.error(`failed to add to solution: ${error.message}`);
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
}
|
|
@@ -94,38 +88,37 @@ async function deploy(webResources, apiConfig, solution, files) {
|
|
|
94
88
|
// publish resources
|
|
95
89
|
if (publishXml.length > 0) {
|
|
96
90
|
try {
|
|
97
|
-
await
|
|
91
|
+
await publish(publishXml.join(''), apiConfig);
|
|
98
92
|
}
|
|
99
93
|
catch (error) {
|
|
100
|
-
|
|
94
|
+
logger.error(error.message);
|
|
101
95
|
}
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
|
-
exports.deploy = deploy;
|
|
105
98
|
async function retrieveResource(name, apiConfig) {
|
|
106
99
|
const options = `$select=webresourceid&$filter=name eq '${name}'`;
|
|
107
|
-
const result = await
|
|
100
|
+
const result = await retrieveMultiple(apiConfig, 'webresourceset', options);
|
|
108
101
|
return result.value.length > 0 ? result.value[0].webresourceid : '';
|
|
109
102
|
}
|
|
110
103
|
async function createResource(resource, content, apiConfig) {
|
|
111
|
-
|
|
104
|
+
logger.info(`create web resource ${resource.name}`);
|
|
112
105
|
const webResource = {
|
|
113
106
|
webresourcetype: getWebResourceType(resource.type),
|
|
114
107
|
name: resource.name,
|
|
115
108
|
displayname: resource.displayname || resource.name,
|
|
116
109
|
content: content
|
|
117
110
|
};
|
|
118
|
-
const result = await
|
|
111
|
+
const result = await createWithReturnData(apiConfig, 'webresourceset', webResource, '$select=webresourceid');
|
|
119
112
|
if (result.error) {
|
|
120
113
|
throw new Error(result.error.message);
|
|
121
114
|
}
|
|
122
115
|
return result.webresourceid;
|
|
123
116
|
}
|
|
124
117
|
async function updateResource(id, resource, content, apiConfig) {
|
|
125
|
-
|
|
118
|
+
logger.info(`update web resource ${resource.name}`);
|
|
126
119
|
const webResource = {
|
|
127
120
|
content: content
|
|
128
121
|
};
|
|
129
|
-
await
|
|
122
|
+
await update(apiConfig, 'webresourceset', id, webResource);
|
|
130
123
|
return `<webresource>{${id}}</webresource>`;
|
|
131
124
|
}
|
package/lib/webResourceDeploy.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.deployWebResource = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const just_scripts_utils_1 = require("just-scripts-utils");
|
|
10
|
-
const webResource_1 = require("./models/webResource");
|
|
11
|
-
async function deployWebResource(creds, apiConfig, files) {
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { logger } from 'just-scripts-utils';
|
|
4
|
+
import { deploy } from './models/webResource';
|
|
5
|
+
export async function deployWebResource(creds, apiConfig, files) {
|
|
12
6
|
const currentPath = '.';
|
|
13
|
-
const configFile =
|
|
7
|
+
const configFile = fs.readFileSync(path.resolve(currentPath, 'dataverse.config.json'), 'utf8');
|
|
14
8
|
if (configFile == null) {
|
|
15
|
-
|
|
9
|
+
logger.warn('unable to find dataverse.config.json file');
|
|
16
10
|
return;
|
|
17
11
|
}
|
|
18
12
|
const config = JSON.parse(configFile).webResources;
|
|
19
|
-
|
|
13
|
+
logger.info('deploy web resources');
|
|
20
14
|
try {
|
|
21
|
-
await
|
|
15
|
+
await deploy(config, apiConfig, creds.solution, files);
|
|
22
16
|
}
|
|
23
17
|
catch (error) {
|
|
24
|
-
|
|
18
|
+
logger.error(error.message);
|
|
25
19
|
return;
|
|
26
20
|
}
|
|
27
|
-
|
|
21
|
+
logger.info('deployed web resources');
|
|
28
22
|
}
|
|
29
|
-
exports.deployWebResource = deployWebResource;
|
package/license
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Derek Finlinson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dataverse-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"description": "Utilities for interacting with Dataverse environments",
|
|
5
6
|
"main": "lib/index.js",
|
|
6
7
|
"bin": {
|
|
7
8
|
"dataverse-utils": "lib/dataverse-utils.js"
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"commander": "^8.2.0",
|
|
24
25
|
"glob": "^7.2.0",
|
|
25
26
|
"cryptr": "^6.0.2",
|
|
26
|
-
"dataverse-webapi": "^2.0.
|
|
27
|
+
"dataverse-webapi": "^2.0.2",
|
|
27
28
|
"envinfo": "^7.8.1",
|
|
28
29
|
"just-scripts-utils": "^1.1.4",
|
|
29
30
|
"prompts": "^2.4.1"
|