@microtronics/studio-cli 0.61.0 → 0.63.0
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/CHANGELOG.md +15 -3
- package/README.md +17 -0
- package/dist/main.js +54 -57
- package/dist/studio-cli.d.ts +1 -0
- package/out/api.js +137 -149
- package/out/studio-cli.d.ts +5297 -0
- package/package.json +4 -4
- package/out/DeviceProfiles.js +0 -436
- package/out/FS.js +0 -43
- package/out/crc.js +0 -93
- package/out/dde/coreDefinitions.js +0 -541
- package/out/dde/dde.js +0 -618
- package/out/dde/dynamic-dde.schema.json +0 -1061
- package/out/dde/fileGenerators/api.js +0 -688
- package/out/dde/fileGenerators/dlo.js +0 -1014
- package/out/dde/fileGenerators/dloLocalData.js +0 -387
- package/out/dde/fileGenerators/xml.js +0 -180
- package/out/dde/yamlDdePreCompiler.js +0 -889
- package/out/defaultFiles.js +0 -114
- package/out/dependencies.js +0 -578
- package/out/dfiles/dfiles.js +0 -205
- package/out/diagnostics.js +0 -10
- package/out/dlo/CustomWasmFS.js +0 -258
- package/out/dlo/compiler.js +0 -231
- package/out/dlo/dlo.js +0 -33
- package/out/dlo/dlocc.js +0 -3799
- package/out/dlo/fileSequencer.js +0 -40
- package/out/dlo/preCompiler.js +0 -442
- package/out/dotenv.js +0 -28
- package/out/globals.js +0 -402
- package/out/helper.js +0 -145
- package/out/log.js +0 -60
- package/out/manifest.js +0 -492
- package/out/myDatanetClient.js +0 -291
- package/out/package/apm.js +0 -294
- package/out/package/library.js +0 -165
- package/out/package/package.js +0 -518
- package/out/registryAPI.js +0 -326
- package/out/scriptRunner.js +0 -107
- package/out/typings/registry.js +0 -7
package/out/package/library.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Library = void 0;
|
|
4
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
5
|
-
const helper_1 = require("../helper");
|
|
6
|
-
var convertBlobToString = helper_1.Helper.convertBlobToString;
|
|
7
|
-
const minimatch_1 = require("minimatch");
|
|
8
|
-
const registryAPI_1 = require("../registryAPI");
|
|
9
|
-
const package_1 = require("./package");
|
|
10
|
-
const globals_1 = require("../globals");
|
|
11
|
-
const tarjs_1 = require("@gera2ld/tarjs");
|
|
12
|
-
const pako = require('pako');
|
|
13
|
-
const STUDIO_IGNORE_FILE = '.studioignore';
|
|
14
|
-
//see original list: https://github.com/microsoft/vscode-vsce/blob/main/src/package.ts#L1603
|
|
15
|
-
const defaultIgnore = [
|
|
16
|
-
'.vscodeignore',
|
|
17
|
-
'package-lock.json',
|
|
18
|
-
'npm-debug.log',
|
|
19
|
-
'yarn.lock',
|
|
20
|
-
'yarn-error.log',
|
|
21
|
-
'npm-shrinkwrap.json',
|
|
22
|
-
'.editorconfig',
|
|
23
|
-
'.npmrc',
|
|
24
|
-
'.yarnrc',
|
|
25
|
-
'.gitattributes',
|
|
26
|
-
'*.todo',
|
|
27
|
-
'tslint.yaml',
|
|
28
|
-
'.eslintrc*',
|
|
29
|
-
'.babelrc*',
|
|
30
|
-
'.prettierrc*',
|
|
31
|
-
'.cz-config.js',
|
|
32
|
-
'.commitlintrc*',
|
|
33
|
-
'webpack.config.js',
|
|
34
|
-
'ISSUE_TEMPLATE.md',
|
|
35
|
-
'CONTRIBUTING.md',
|
|
36
|
-
'PULL_REQUEST_TEMPLATE.md',
|
|
37
|
-
'CODE_OF_CONDUCT.md',
|
|
38
|
-
'.github',
|
|
39
|
-
'.travis.yml',
|
|
40
|
-
'appveyor.yml',
|
|
41
|
-
'**/.git',
|
|
42
|
-
'**/.git/**',
|
|
43
|
-
'**/*.vsix',
|
|
44
|
-
'**/.DS_Store',
|
|
45
|
-
'**/*.vsixmanifest',
|
|
46
|
-
'**/.vscode-test/**',
|
|
47
|
-
'**/.vscode-test-web/**'
|
|
48
|
-
];
|
|
49
|
-
defaultIgnore.push(...['**/.studio/**', '**/node_modules/**', STUDIO_IGNORE_FILE, 'dist/defines.app.ts']);
|
|
50
|
-
const MINIMATCH_OPTIONS = { dot: true };
|
|
51
|
-
var Library;
|
|
52
|
-
(function (Library) {
|
|
53
|
-
/**
|
|
54
|
-
* Creates the library.tar.gz archive content
|
|
55
|
-
* @param cwd
|
|
56
|
-
* @param fs
|
|
57
|
-
*/
|
|
58
|
-
async function createArchive(cwd, fs) {
|
|
59
|
-
const tar = new tarjs_1.TarWriter();
|
|
60
|
-
const filesToPack = await getFilesForArchive(cwd, fs);
|
|
61
|
-
filesToPack.forEach(file => {
|
|
62
|
-
tar.addFile(file.name, file.data);
|
|
63
|
-
});
|
|
64
|
-
const tarBuffer = await tar.write();
|
|
65
|
-
return pako.gzip(await tarBuffer.arrayBuffer());
|
|
66
|
-
}
|
|
67
|
-
Library.createArchive = createArchive;
|
|
68
|
-
/**
|
|
69
|
-
* Reads the project directory and returns all files that will be packed within the library.tar.gz
|
|
70
|
-
* @param cwd
|
|
71
|
-
* @param fs
|
|
72
|
-
*/
|
|
73
|
-
async function getFilesForArchive(cwd, fs) {
|
|
74
|
-
const files = [];
|
|
75
|
-
const { ignore, negate } = await getIgnoreNegateList(cwd, fs);
|
|
76
|
-
const allFiles = await fs.findFiles(cwd, '**/*');
|
|
77
|
-
const filteredFiles = allFiles.filter(({ path }) => {
|
|
78
|
-
const relativePath = path.slice(cwd.path.length + 1);
|
|
79
|
-
return (!ignore.some(i => (0, minimatch_1.minimatch)(relativePath, i, MINIMATCH_OPTIONS)) ||
|
|
80
|
-
negate.some(i => (0, minimatch_1.minimatch)(relativePath, i.slice(1), MINIMATCH_OPTIONS)));
|
|
81
|
-
});
|
|
82
|
-
for (const fileUri of filteredFiles) {
|
|
83
|
-
const relativePath = fileUri.path.slice(cwd.path.length + 1);
|
|
84
|
-
const [stat, blob] = await Promise.all([fs.stat(fileUri), fs.readFile(fileUri)]);
|
|
85
|
-
if (stat) {
|
|
86
|
-
files.push({
|
|
87
|
-
name: relativePath,
|
|
88
|
-
data: blob,
|
|
89
|
-
modifyTime: new Date(stat.mtime)
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return files;
|
|
94
|
-
}
|
|
95
|
-
Library.getFilesForArchive = getFilesForArchive;
|
|
96
|
-
/**
|
|
97
|
-
* Publish new library package to the registry
|
|
98
|
-
* @param cwd
|
|
99
|
-
* @param fs
|
|
100
|
-
* @param token
|
|
101
|
-
* @param archive
|
|
102
|
-
* @param env
|
|
103
|
-
*/
|
|
104
|
-
async function publishPackage(token, manifest, archive, env = globals_1.Globals.ENV.production) {
|
|
105
|
-
const { publisher, name, version } = manifest;
|
|
106
|
-
const extractedFiles = await package_1.Package.readFilesFromTarGz(archive, ['CHANGELOG.md', 'README.md', 'studio.json']);
|
|
107
|
-
const files = {
|
|
108
|
-
'CHANGELOG.md': await blobToUint8Array(extractedFiles['CHANGELOG.md']),
|
|
109
|
-
'README.md': await blobToUint8Array(extractedFiles['README.md']),
|
|
110
|
-
'studio.json': await blobToUint8Array(extractedFiles['studio.json']),
|
|
111
|
-
'library.tar.gz': archive
|
|
112
|
-
};
|
|
113
|
-
return await registryAPI_1.Registry.publishLibraryVersion(token, publisher, name, version, files, env);
|
|
114
|
-
}
|
|
115
|
-
Library.publishPackage = publishPackage;
|
|
116
|
-
})(Library || (exports.Library = Library = {}));
|
|
117
|
-
/**
|
|
118
|
-
* Parse the studioignore file and returns a list of ignore files and negations
|
|
119
|
-
* @param cwd
|
|
120
|
-
* @param fs
|
|
121
|
-
*/
|
|
122
|
-
async function getIgnoreNegateList(cwd, fs) {
|
|
123
|
-
const notIgnored = ['!studio.json', `!README.md`];
|
|
124
|
-
// this code is mostly from https://github.com/microsoft/vscode-vsce/blob/main/src/package.ts#L1681
|
|
125
|
-
const ignoreFile = await getIgnoreFile(cwd, fs);
|
|
126
|
-
// Parse raw ignore by splitting output into lines and filtering out empty lines and comments
|
|
127
|
-
const filteredIgnore = ignoreFile
|
|
128
|
-
.split(/[\n\r]/)
|
|
129
|
-
.map(s => s.trim())
|
|
130
|
-
.filter(s => !!s)
|
|
131
|
-
.filter(i => !/^\s*#/.test(i));
|
|
132
|
-
// Add '/**' to possible folders
|
|
133
|
-
const folderAgnosticIgnore = [
|
|
134
|
-
...filteredIgnore,
|
|
135
|
-
...filteredIgnore.filter(i => !/(^|\/)[^/]*\*[^/]*$/.test(i)).map(i => (/\/$/.test(i) ? `${i}**` : `${i}/**`))
|
|
136
|
-
];
|
|
137
|
-
// Combine with default ignore list
|
|
138
|
-
const combinedIgnoreList = [...defaultIgnore, ...folderAgnosticIgnore, ...notIgnored];
|
|
139
|
-
// Split into ignore and negate list
|
|
140
|
-
const [ignore, negate] = combinedIgnoreList.reduce((r, e) => (!/^\s*!/.test(e) ? [[...r[0], e], r[1]] : [r[0], [...r[1], e]]), [[], []]);
|
|
141
|
-
return {
|
|
142
|
-
ignore,
|
|
143
|
-
negate
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Reads the .studioignore file if exist
|
|
148
|
-
* @param cwd
|
|
149
|
-
* @param fs
|
|
150
|
-
*/
|
|
151
|
-
async function getIgnoreFile(cwd, fs) {
|
|
152
|
-
const ignoreFilePath = vscode_uri_1.Utils.joinPath(cwd, STUDIO_IGNORE_FILE);
|
|
153
|
-
const exists = await fs.stat(ignoreFilePath);
|
|
154
|
-
if (exists) {
|
|
155
|
-
const ignoreFile = await fs.readFile(ignoreFilePath);
|
|
156
|
-
return convertBlobToString(ignoreFile);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
return '';
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
async function blobToUint8Array(blob) {
|
|
163
|
-
return new Uint8Array(await blob.arrayBuffer());
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=library.js.map
|
package/out/package/package.js
DELETED
|
@@ -1,518 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Package = void 0;
|
|
4
|
-
exports.readManifestFromArchive = readManifestFromArchive;
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
6
|
-
const helper_1 = require("../helper");
|
|
7
|
-
const defaultFiles_1 = require("../defaultFiles");
|
|
8
|
-
var convertBlobToString = helper_1.Helper.convertBlobToString;
|
|
9
|
-
const apm_1 = require("./apm");
|
|
10
|
-
const dde_1 = require("../dde/dde");
|
|
11
|
-
const dlo_1 = require("../dlo/dlo");
|
|
12
|
-
const compiler_1 = require("../dlo/compiler");
|
|
13
|
-
const scriptRunner_1 = require("../scriptRunner");
|
|
14
|
-
const registryAPI_1 = require("../registryAPI");
|
|
15
|
-
const manifest_1 = require("../manifest");
|
|
16
|
-
const globals_1 = require("../globals");
|
|
17
|
-
const library_1 = require("./library");
|
|
18
|
-
const dfiles_1 = require("../dfiles/dfiles");
|
|
19
|
-
const tarjs_1 = require("@gera2ld/tarjs");
|
|
20
|
-
const pako = require('pako');
|
|
21
|
-
var Package;
|
|
22
|
-
(function (Package) {
|
|
23
|
-
class BuildError extends Error {
|
|
24
|
-
_mergedDiagnostics;
|
|
25
|
-
constructor(message, mergedDiagnostics) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.name = 'BuildError';
|
|
28
|
-
this._mergedDiagnostics = mergedDiagnostics;
|
|
29
|
-
}
|
|
30
|
-
get mergedDiagnostics() {
|
|
31
|
-
return this._mergedDiagnostics;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
Package.BuildError = BuildError;
|
|
35
|
-
/**
|
|
36
|
-
* Build the whole project or only a specific part
|
|
37
|
-
* @param cwd
|
|
38
|
-
* @param fs
|
|
39
|
-
* @param logger
|
|
40
|
-
* @param selectedParts - choose a specific part that should be build or if true all parts are build
|
|
41
|
-
* @param errorWithDiagnostics
|
|
42
|
-
*/
|
|
43
|
-
async function buildAll(cwd, fs, logger, env, apiToken, selectedParts = true, errorWithDiagnostics) {
|
|
44
|
-
selectedParts = normalizeSelectedParts(logger, selectedParts);
|
|
45
|
-
await preBuild(cwd, fs, logger, env, apiToken, selectedParts);
|
|
46
|
-
// Generate dist/defines.ts before POV/BLO builds
|
|
47
|
-
try {
|
|
48
|
-
const resolvedConfig = await globals_1.Globals.read(cwd, fs, logger);
|
|
49
|
-
await exportDefinesForProject(cwd, fs, logger, resolvedConfig);
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
logger.warn('Could not generate defines.ts:', e);
|
|
53
|
-
}
|
|
54
|
-
const mergedDiagnostics = {
|
|
55
|
-
[apm_1.APM.Part.dde]: [],
|
|
56
|
-
[apm_1.APM.Part.dlo]: [],
|
|
57
|
-
[apm_1.APM.Part.dfiles]: []
|
|
58
|
-
};
|
|
59
|
-
// Helper for building parts
|
|
60
|
-
const buildMapping = {
|
|
61
|
-
[apm_1.APM.Part.dde]: buildDDE,
|
|
62
|
-
[apm_1.APM.Part.dlo]: buildDLO,
|
|
63
|
-
[apm_1.APM.Part.dfiles]: buildDfiles
|
|
64
|
-
};
|
|
65
|
-
try {
|
|
66
|
-
// Build and validate specific parts
|
|
67
|
-
for (const part of [apm_1.APM.Part.dde, apm_1.APM.Part.dlo, apm_1.APM.Part.dfiles]) {
|
|
68
|
-
if (selectedParts.includes(part)) {
|
|
69
|
-
logger.info(`Building ${part.toUpperCase()}...`);
|
|
70
|
-
const hasError = await buildAndValidatePart(logger, part,
|
|
71
|
-
/*@ts-ignore*/
|
|
72
|
-
buildMapping[part],
|
|
73
|
-
/*@ts-ignore*/
|
|
74
|
-
mergedDiagnostics[part], cwd, fs);
|
|
75
|
-
if (hasError) {
|
|
76
|
-
return mergedDiagnostics; // Early exit on error
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch (e) {
|
|
82
|
-
if (errorWithDiagnostics) {
|
|
83
|
-
throw new BuildError(e?.message, mergedDiagnostics);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
throw e;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// Handle pov and blo parts that do not return diagnostics
|
|
90
|
-
if (selectedParts.includes(apm_1.APM.Part.pov)) {
|
|
91
|
-
await scriptRunner_1.Shell.tryBuildPov(cwd, fs, logger);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
logger.info('Skipping pov build');
|
|
95
|
-
}
|
|
96
|
-
if (selectedParts.includes(apm_1.APM.Part.blo)) {
|
|
97
|
-
await scriptRunner_1.Shell.tryBuildBlo(cwd, fs, logger);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
logger.info('Skipping blo build');
|
|
101
|
-
}
|
|
102
|
-
await processAdditionalFiles(cwd, fs, logger);
|
|
103
|
-
logger.done('Project build completed.');
|
|
104
|
-
return mergedDiagnostics;
|
|
105
|
-
}
|
|
106
|
-
Package.buildAll = buildAll;
|
|
107
|
-
/**
|
|
108
|
-
* Trigger the release based on the manifest settings
|
|
109
|
-
* @param cwd
|
|
110
|
-
* @param fs
|
|
111
|
-
* @param logger
|
|
112
|
-
* @param token
|
|
113
|
-
* @param releasePhase
|
|
114
|
-
* @param allowedBackends
|
|
115
|
-
* @param env
|
|
116
|
-
*/
|
|
117
|
-
async function release(cwd, fs, logger, env, token, releasePhase, allowedBackends) {
|
|
118
|
-
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
119
|
-
if (manifest_1.Manifest.isLibrary(manifest)) {
|
|
120
|
-
logger.info('Library project detected. Publishing library...');
|
|
121
|
-
return releaseLibrary(cwd, fs, logger, token, env);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
logger.info('App project detected. Publishing app...');
|
|
125
|
-
return releaseAPM(cwd, fs, logger, token, releasePhase, allowedBackends, env);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
Package.release = release;
|
|
129
|
-
async function pack(cwd, fs, logger, env, token, releasePhase) {
|
|
130
|
-
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
131
|
-
const archiveName = `${manifest.name}-${manifest.version}.tar.gz`;
|
|
132
|
-
let archive = null;
|
|
133
|
-
if (manifest_1.Manifest.isLibrary(manifest)) {
|
|
134
|
-
logger.info('Library project detected. Packing library...');
|
|
135
|
-
archive = await createLibraryPackage(cwd, fs, logger, token, env);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
logger.info('App project detected. Packing app...');
|
|
139
|
-
const apmTag = await createAPMPackage(cwd, fs, logger, token, releasePhase, env);
|
|
140
|
-
archive = await createArchiveFromApmPackage(apmTag);
|
|
141
|
-
}
|
|
142
|
-
const archivePath = vscode_uri_1.Utils.joinPath(cwd, archiveName);
|
|
143
|
-
if (archive !== null) {
|
|
144
|
-
await fs.writeFile(archivePath, archive);
|
|
145
|
-
logger.done(`Packaged: ${archivePath.fsPath}`);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
logger.error(`Could not create archive: ${archivePath.fsPath}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
Package.pack = pack;
|
|
152
|
-
/**
|
|
153
|
-
* Publish an application model tag
|
|
154
|
-
* @param cwd
|
|
155
|
-
* @param fs
|
|
156
|
-
* @param logger
|
|
157
|
-
* @param token
|
|
158
|
-
* @param releasePhase
|
|
159
|
-
* @param allowedBackends
|
|
160
|
-
* @param env
|
|
161
|
-
*/
|
|
162
|
-
async function releaseAPM(cwd, fs, logger, token, releasePhase, allowedBackends = null, env) {
|
|
163
|
-
const application = await apm_1.APM.validateAccess(cwd, fs, token, false, env);
|
|
164
|
-
if (!application) {
|
|
165
|
-
throw new Error('Could not validate access to application');
|
|
166
|
-
}
|
|
167
|
-
const tagContent = await createAPMPackage(cwd, fs, logger, token, releasePhase, env);
|
|
168
|
-
// update the store apm with the actual name/description/...
|
|
169
|
-
await apm_1.APM.updateProfile(cwd, fs, token, env);
|
|
170
|
-
const newTag = await apm_1.APM.publishTag(cwd, fs, token, tagContent, env);
|
|
171
|
-
if (allowedBackends !== null) {
|
|
172
|
-
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
173
|
-
// update tag with content
|
|
174
|
-
await registryAPI_1.Registry.updateExistingApplicationVersion(token, manifest.publisher, manifest.registry?.id, manifest.version, {
|
|
175
|
-
allowedBackends
|
|
176
|
-
}, env);
|
|
177
|
-
logger.info(`Tag "${newTag.version}" with phase "${newTag.phase}" shared with ${[...allowedBackends].join(';')}!`);
|
|
178
|
-
}
|
|
179
|
-
logger.done(`Tag "${newTag.version}" with phase "${newTag.phase}" published!`);
|
|
180
|
-
}
|
|
181
|
-
Package.releaseAPM = releaseAPM;
|
|
182
|
-
/**
|
|
183
|
-
* Publish a library project
|
|
184
|
-
* @param cwd
|
|
185
|
-
* @param fs
|
|
186
|
-
* @param logger
|
|
187
|
-
* @param token
|
|
188
|
-
* @param env
|
|
189
|
-
*/
|
|
190
|
-
async function releaseLibrary(cwd, fs, logger, token, env) {
|
|
191
|
-
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
192
|
-
const archive = await createLibraryPackage(cwd, fs, logger, token, env);
|
|
193
|
-
await library_1.Library.publishPackage(token, manifest, archive, env);
|
|
194
|
-
logger.done(`Library "${manifest.publisher}/${manifest.name}" with version "${manifest.version}" published!`);
|
|
195
|
-
}
|
|
196
|
-
Package.releaseLibrary = releaseLibrary;
|
|
197
|
-
/**
|
|
198
|
-
* Publishes an archive package to the appropriate library or application registry.
|
|
199
|
-
*
|
|
200
|
-
* @param {URI} cwd - The current working directory where the package archive is located.
|
|
201
|
-
* @param {LocalFS} fs - The file system interface for reading and writing files.
|
|
202
|
-
* @param {Log.Logger} logger - The logger instance for logging messages during the operation.
|
|
203
|
-
* @param {Registry.AuthToken} token - The authorization token required for interacting with the registry.
|
|
204
|
-
* @param {Globals.ENV} env - The global environment settings.
|
|
205
|
-
* @param {string} packagePath - The relative path to the archive package to be published.
|
|
206
|
-
* @param {APM.TagPhase} [releasePhase] - An optional release phase for tagging the published version of the application.
|
|
207
|
-
* @param {Registry.ApiNewApplication['allowedBackends']} [allowedBackends] - An optional list of allowed backends for the published version.
|
|
208
|
-
*
|
|
209
|
-
* @return {Promise<void>} A promise that resolves when the publication process completes successfully.
|
|
210
|
-
*/
|
|
211
|
-
async function publishArchive(cwd, fs, logger, token, env, packagePath, releasePhase, allowedBackends = null) {
|
|
212
|
-
if (packagePath === '*') {
|
|
213
|
-
const localManifest = await manifest_1.Manifest.read(cwd, fs);
|
|
214
|
-
packagePath = `${localManifest.name}-${localManifest.version}.tar.gz`;
|
|
215
|
-
logger.info(`Publishing detected archive package "${packagePath}"...`);
|
|
216
|
-
}
|
|
217
|
-
const archivePath = vscode_uri_1.Utils.joinPath(cwd, packagePath);
|
|
218
|
-
if (!(await fs.stat(archivePath))) {
|
|
219
|
-
throw new Error(`Archive package not found: ${archivePath.fsPath}`);
|
|
220
|
-
}
|
|
221
|
-
const archive = await fs.readFile(archivePath);
|
|
222
|
-
const manifest = await readManifestFromArchive(archive);
|
|
223
|
-
const { publisher, registry, version } = manifest;
|
|
224
|
-
// add library publishing.
|
|
225
|
-
if (manifest_1.Manifest.isLibrary(manifest)) {
|
|
226
|
-
await library_1.Library.publishPackage(token, manifest, archive, env);
|
|
227
|
-
logger.done(`Library "${publisher}/${manifest.name}" with version "${manifest.version}" published!`);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
await registryAPI_1.Registry.updateApplicationFile(token, publisher, registry.id, version, 'app.tar.gz', archive, env);
|
|
231
|
-
// update the version profile
|
|
232
|
-
await registryAPI_1.Registry.updateExistingApplicationVersion(token, publisher, registry?.id, version, {
|
|
233
|
-
allowedBackends: allowedBackends || undefined,
|
|
234
|
-
phase: releasePhase || undefined
|
|
235
|
-
}, env);
|
|
236
|
-
logger.info(`Tag "${version}" with phase "${releasePhase}" shared with ${[...(allowedBackends || '')].join(';')}!`);
|
|
237
|
-
logger.done(`Tag "${version}" with phase "${releasePhase}" published!`);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
Package.publishArchive = publishArchive;
|
|
241
|
-
/**
|
|
242
|
-
* Read the projects README.md file
|
|
243
|
-
* validates if the file content is the initial content
|
|
244
|
-
* @param cwd
|
|
245
|
-
* @param fs
|
|
246
|
-
* @param projectName
|
|
247
|
-
*/
|
|
248
|
-
async function getReadmeFile(cwd, fs, projectName) {
|
|
249
|
-
let fileBlob = undefined;
|
|
250
|
-
try {
|
|
251
|
-
fileBlob = await fs.readFile(vscode_uri_1.Utils.joinPath(cwd, 'README.md'));
|
|
252
|
-
}
|
|
253
|
-
catch (e) {
|
|
254
|
-
throw new Error('Could not find "README.md". "README.md" is required for publishing.');
|
|
255
|
-
}
|
|
256
|
-
const README_STRING = convertBlobToString(fileBlob);
|
|
257
|
-
if (README_STRING === defaultFiles_1.DefaultFiles.readme(projectName)) {
|
|
258
|
-
throw new Error('"README.md" matches the default template. Please write a brief project description.');
|
|
259
|
-
}
|
|
260
|
-
return fileBlob;
|
|
261
|
-
}
|
|
262
|
-
Package.getReadmeFile = getReadmeFile;
|
|
263
|
-
/**
|
|
264
|
-
* Read the projects CHANGELOG.md file
|
|
265
|
-
* validates if the file content is the initial content
|
|
266
|
-
* @param cwd
|
|
267
|
-
* @param fs
|
|
268
|
-
*/
|
|
269
|
-
async function getChangelogFile(cwd, fs) {
|
|
270
|
-
let fileBlob = undefined;
|
|
271
|
-
try {
|
|
272
|
-
fileBlob = await fs.readFile(vscode_uri_1.Utils.joinPath(cwd, 'CHANGELOG.md'));
|
|
273
|
-
}
|
|
274
|
-
catch (e) {
|
|
275
|
-
throw new Error('Could not find "CHANGELOG.md". "CHANGELOG.md" is required for publishing.');
|
|
276
|
-
}
|
|
277
|
-
const CHANGELOG_STRING = convertBlobToString(fileBlob);
|
|
278
|
-
if (CHANGELOG_STRING === defaultFiles_1.DefaultFiles.changelog) {
|
|
279
|
-
throw new Error('"CHANGELOG.md" matches the default template.');
|
|
280
|
-
}
|
|
281
|
-
return fileBlob;
|
|
282
|
-
}
|
|
283
|
-
Package.getChangelogFile = getChangelogFile;
|
|
284
|
-
/**
|
|
285
|
-
* Validate manifest settings that are required for the APM
|
|
286
|
-
* @param cwd
|
|
287
|
-
* @param fs
|
|
288
|
-
* @param token
|
|
289
|
-
* @param env
|
|
290
|
-
*/
|
|
291
|
-
async function validatePublishSettings(cwd, fs, token, env) {
|
|
292
|
-
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
293
|
-
const { name, publisher, description } = manifest;
|
|
294
|
-
const invalidName = manifest_1.Manifest.validateProjectName(name, manifest_1.Manifest.isLibrary(manifest));
|
|
295
|
-
if (invalidName) {
|
|
296
|
-
throw new Error(`name: ${invalidName}`);
|
|
297
|
-
}
|
|
298
|
-
const invalidDescription = manifest_1.Manifest.validateDescription(description);
|
|
299
|
-
if (invalidDescription) {
|
|
300
|
-
throw new Error(`description: ${invalidDescription}`);
|
|
301
|
-
}
|
|
302
|
-
const invalidPublisher = manifest_1.Manifest.validatePublisherId(publisher) || (await manifest_1.Manifest.validatePublisherOnline(token, publisher, env));
|
|
303
|
-
if (invalidPublisher) {
|
|
304
|
-
throw new Error(`publisher: ${invalidPublisher}`);
|
|
305
|
-
}
|
|
306
|
-
// only validate if the project is not a library project
|
|
307
|
-
if (!manifest_1.Manifest.isLibrary(manifest)) {
|
|
308
|
-
await manifest_1.Manifest.validateApplicationIcon(cwd, fs, manifest);
|
|
309
|
-
manifest_1.Manifest.validateEngineSettings(manifest);
|
|
310
|
-
// validate for dpid
|
|
311
|
-
if (manifest_1.Manifest.isApp(manifest) &&
|
|
312
|
-
(await manifest_1.Manifest.isApmPartEnabled(cwd, fs, apm_1.APM.Part.dlo, manifest)) &&
|
|
313
|
-
(!manifest.dpid || !Object.values(manifest_1.Manifest.DeviceProfiles).includes(manifest.dpid))) {
|
|
314
|
-
throw new Error(`dpid: The device profile is needed to compile a dlo`);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
Package.validatePublishSettings = validatePublishSettings;
|
|
319
|
-
async function readFilesFromTarGz(gzipped, fileNames) {
|
|
320
|
-
// Decompress GZ
|
|
321
|
-
const tarData = pako.ungzip(gzipped);
|
|
322
|
-
// Parse TAR with tarballjs
|
|
323
|
-
const tarReader = await tarjs_1.TarReader.load(tarData);
|
|
324
|
-
const fileList = {};
|
|
325
|
-
for (const entry of tarReader.fileInfos) {
|
|
326
|
-
if (fileNames.includes(entry.name)) {
|
|
327
|
-
// Return file contents as a Buffer
|
|
328
|
-
fileList[entry.name] = tarReader.getFileBlob(entry.name);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
// File not found
|
|
332
|
-
return fileList;
|
|
333
|
-
}
|
|
334
|
-
Package.readFilesFromTarGz = readFilesFromTarGz;
|
|
335
|
-
})(Package || (exports.Package = Package = {}));
|
|
336
|
-
/**
|
|
337
|
-
* Normalize the selected parts parameter for building.
|
|
338
|
-
* @param logger - Logger for generic logging
|
|
339
|
-
* @param selectedParts - Can be a boolean or parts array. True selects all parts, false selects none.
|
|
340
|
-
* @returns Normalized array of parts.
|
|
341
|
-
*/
|
|
342
|
-
function normalizeSelectedParts(logger, selectedParts) {
|
|
343
|
-
const ALL_PARTS = Object.values(apm_1.APM.Part);
|
|
344
|
-
if (selectedParts === true) {
|
|
345
|
-
logger.info('Building project...');
|
|
346
|
-
return ALL_PARTS;
|
|
347
|
-
}
|
|
348
|
-
if (selectedParts === false) {
|
|
349
|
-
return [];
|
|
350
|
-
}
|
|
351
|
-
return selectedParts;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Prepares the build process by performing pre-build operations based on the selected parts.
|
|
355
|
-
*
|
|
356
|
-
* @param {URI} cwd - The current working directory for the build process.
|
|
357
|
-
* @param {LocalFS} fs - The file system abstraction used for file operations.
|
|
358
|
-
* @param {Log.Logger} logger - The logger instance for logging messages during the process.
|
|
359
|
-
* @param {Globals.ENV} env - The environment variables and configuration for the process.
|
|
360
|
-
* @param {string|null} apiToken - The API token used for authentication, or null if not required.
|
|
361
|
-
* @param {APM.Part[]} selectedParts - An array of selected parts indicating specific build steps to execute.
|
|
362
|
-
* @return {Promise<void>} A promise that resolves when the pre-build process completes.
|
|
363
|
-
*/
|
|
364
|
-
async function preBuild(cwd, fs, logger, env, apiToken, selectedParts) {
|
|
365
|
-
if (selectedParts.includes(apm_1.APM.Part.dde)) {
|
|
366
|
-
await dde_1.DDE.fetchPreviousHistoryJson(cwd, fs, logger, env, apiToken);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Export defines.ts file(s) based on project type.
|
|
371
|
-
* Library projects get two files: dist/defines.ts (defaults only) and dist/defines.app.ts (full merged).
|
|
372
|
-
* App/addon/analytics projects get a single dist/defines.ts with all merged values.
|
|
373
|
-
*/
|
|
374
|
-
async function exportDefinesForProject(cwd, fs, logger, resolvedConfig) {
|
|
375
|
-
if (resolvedConfig.defaultsOnly) {
|
|
376
|
-
// Library: dist/defines.ts = defaults only (for publishing)
|
|
377
|
-
await globals_1.Globals.exportDefinesTs(cwd, fs, resolvedConfig.defaultsOnly);
|
|
378
|
-
logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.dist.definesTs, '(defaults only)');
|
|
379
|
-
// Library: dist/defines.app.ts = full merged (for local dev)
|
|
380
|
-
await globals_1.Globals.exportDefinesTs(cwd, fs, resolvedConfig, defaultFiles_1.DefaultFiles.filePaths.dist.definesAppTs);
|
|
381
|
-
logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.dist.definesAppTs, '(with app.ini overrides)');
|
|
382
|
-
}
|
|
383
|
-
else {
|
|
384
|
-
// App/addon/analytics: single merged file
|
|
385
|
-
await globals_1.Globals.exportDefinesTs(cwd, fs, resolvedConfig);
|
|
386
|
-
logger.log('Generated', defaultFiles_1.DefaultFiles.filePaths.dist.definesTs);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Generates all needed files out of the dde declaration
|
|
391
|
-
* @param cwd
|
|
392
|
-
* @param fs
|
|
393
|
-
* @param logger
|
|
394
|
-
*/
|
|
395
|
-
async function buildDDE(cwd, fs, logger) {
|
|
396
|
-
const result = await dde_1.DDE.compileDDE(cwd, fs, logger);
|
|
397
|
-
if (result.ddeJSON) {
|
|
398
|
-
await dde_1.DDE.exportMyDatanetXML(cwd, fs, logger, result.ddeJSON);
|
|
399
|
-
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
400
|
-
// a library does not need a history.json
|
|
401
|
-
if (!manifest_1.Manifest.isLibrary(manifest)) {
|
|
402
|
-
await dde_1.DDE.exportHistoryJson(cwd, fs, logger, result.ddeJSON);
|
|
403
|
-
}
|
|
404
|
-
await dde_1.DDE.exportOpenApi(cwd, fs, logger, result.ddeJSON);
|
|
405
|
-
if (await manifest_1.Manifest.isApmPartEnabled(cwd, fs, apm_1.APM.Part.dlo, manifest)) {
|
|
406
|
-
await dde_1.DDE.exportAutoDloFiles(cwd, fs, logger, result.ddeJSON);
|
|
407
|
-
await dlo_1.DLO.exportDloConfig(cwd, fs, logger);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return result.diagnostics;
|
|
411
|
-
}
|
|
412
|
-
async function buildDLO(cwd, fs, logger) {
|
|
413
|
-
const compiler = new compiler_1.DloCompiler(cwd, fs, logger);
|
|
414
|
-
const { diagnostics } = await compiler.compile(cwd, fs);
|
|
415
|
-
return diagnostics;
|
|
416
|
-
}
|
|
417
|
-
async function buildDfiles(cwd, fs, logger) {
|
|
418
|
-
return await dfiles_1.DFILES.process(cwd, fs, logger);
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Handle additional files like `mdn_report_template.json`
|
|
422
|
-
* @private
|
|
423
|
-
*/
|
|
424
|
-
async function processAdditionalFiles(cwd, fs, logger) {
|
|
425
|
-
const reportTemplate = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.fileNames.reportTemplate);
|
|
426
|
-
if (await fs.stat(reportTemplate)) {
|
|
427
|
-
const distFolder = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.reportTemplate);
|
|
428
|
-
await fs.copy(reportTemplate, distFolder);
|
|
429
|
-
logger.log(`Copied "${defaultFiles_1.DefaultFiles.fileNames.reportTemplate}" to dist folder.`);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
function validateDiagnostics(logger, apmPart, diagnostics) {
|
|
433
|
-
if (apmPart !== apm_1.APM.Part.dlo) {
|
|
434
|
-
// dlo compiler does log diagnostics by itself
|
|
435
|
-
logDiagnostics(logger, diagnostics);
|
|
436
|
-
}
|
|
437
|
-
const hasErrors = diagnostics.some(diagnostic => diagnostic.level === 'error');
|
|
438
|
-
if (hasErrors) {
|
|
439
|
-
const message = `APM part "${apmPart}" has errors. Aborted.`;
|
|
440
|
-
throw new Error(message);
|
|
441
|
-
}
|
|
442
|
-
return hasErrors;
|
|
443
|
-
}
|
|
444
|
-
async function buildAndValidatePart(logger, part, buildFn, mergedDiagnostics, cwd, fs) {
|
|
445
|
-
const diagnostics = await buildFn(cwd, fs, logger);
|
|
446
|
-
mergedDiagnostics.push(...diagnostics);
|
|
447
|
-
return validateDiagnostics(logger, part, diagnostics);
|
|
448
|
-
}
|
|
449
|
-
function logDiagnostics(logger, diagnostics) {
|
|
450
|
-
diagnostics.forEach(diagnostic => {
|
|
451
|
-
// diagnostic.line and startCharacter are zero based. Therefor we need to increment with 1.
|
|
452
|
-
const startChar = diagnostic.startCharacter ? `:${diagnostic.startCharacter + 1}` : '';
|
|
453
|
-
const message = `${diagnostic.file.path}:${diagnostic.line + 1}${startChar} - ${diagnostic.message}`;
|
|
454
|
-
if (diagnostic.level === 'error') {
|
|
455
|
-
logger.error(message);
|
|
456
|
-
}
|
|
457
|
-
else if (diagnostic.level === 'warning') {
|
|
458
|
-
logger.warn(message);
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
logger.log(message);
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
async function createLibraryPackage(cwd, fs, logger, token, env) {
|
|
466
|
-
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
467
|
-
await manifest_1.Manifest.validateBasicManifest(cwd, fs, manifest);
|
|
468
|
-
// build the complete project
|
|
469
|
-
await Package.buildAll(cwd, fs, logger, env, token);
|
|
470
|
-
return await library_1.Library.createArchive(cwd, fs);
|
|
471
|
-
}
|
|
472
|
-
async function createAPMPackage(cwd, fs, logger, token, releasePhase, env) {
|
|
473
|
-
if (!Object.values(apm_1.APM.TagPhase).includes(releasePhase)) {
|
|
474
|
-
throw new Error(`ReleasePhase: ${releasePhase} is not a valid release phase`);
|
|
475
|
-
}
|
|
476
|
-
await manifest_1.Manifest.validateBasicManifest(cwd, fs, null);
|
|
477
|
-
// build the complete project
|
|
478
|
-
await Package.buildAll(cwd, fs, logger, env, token);
|
|
479
|
-
return await apm_1.APM.createTag(cwd, fs, releasePhase);
|
|
480
|
-
}
|
|
481
|
-
async function createArchiveFromApmPackage(data) {
|
|
482
|
-
const tar = new tarjs_1.TarWriter();
|
|
483
|
-
// @ts-ignore .entries is valid on FormData
|
|
484
|
-
for (const [name, value] of data.entries()) {
|
|
485
|
-
if (name === 'tag') {
|
|
486
|
-
const fileNode = value;
|
|
487
|
-
tar.addFile(name, fileNode);
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
const fileNode = value;
|
|
491
|
-
tar.addFile(name, await fileNode.arrayBuffer());
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
const tarBuffer = await tar.write();
|
|
495
|
-
return pako.gzip(await tarBuffer.arrayBuffer());
|
|
496
|
-
}
|
|
497
|
-
async function readManifestFromArchive(archive) {
|
|
498
|
-
const manifestData = await readFileFromTarGz(archive, ['studio.json', 'src/studio.json']);
|
|
499
|
-
if (!manifestData) {
|
|
500
|
-
throw new Error(`Could not find "studio.json" in archive`);
|
|
501
|
-
}
|
|
502
|
-
return JSON.parse(await manifestData.text());
|
|
503
|
-
}
|
|
504
|
-
async function readFileFromTarGz(gzipped, possibleFilenames) {
|
|
505
|
-
// Decompress GZ
|
|
506
|
-
const tarData = pako.ungzip(gzipped);
|
|
507
|
-
// Parse TAR with tarballjs
|
|
508
|
-
const tarReader = await tarjs_1.TarReader.load(tarData);
|
|
509
|
-
for (const entry of tarReader.fileInfos) {
|
|
510
|
-
if (possibleFilenames.includes(entry.name)) {
|
|
511
|
-
// Return file contents as a Buffer
|
|
512
|
-
return tarReader.getFileBlob(entry.name);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
// File not found
|
|
516
|
-
return null;
|
|
517
|
-
}
|
|
518
|
-
//# sourceMappingURL=package.js.map
|