@rancher/shell 1.2.3 → 1.2.5
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/assets/translations/en-us.yaml +49 -18
- package/assets/translations/zh-hans.yaml +1 -0
- package/cloud-credential/__tests__/harvester.test.ts +18 -0
- package/cloud-credential/harvester.vue +9 -1
- package/components/AlertTable.vue +17 -7
- package/components/GrafanaDashboard.vue +6 -4
- package/components/nav/Header.vue +9 -5
- package/components/nav/TopLevelMenu.vue +1 -4
- package/config/product/explorer.js +11 -4
- package/config/settings.ts +9 -2
- package/config/types.js +1 -1
- package/config/uiplugins.js +2 -2
- package/detail/catalog.cattle.io.app.vue +17 -4
- package/edit/management.cattle.io.setting.vue +15 -2
- package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +8 -2
- package/edit/provisioning.cattle.io.cluster/__tests__/RegistryConfigs.test.ts +61 -0
- package/edit/provisioning.cattle.io.cluster/__tests__/utils/cluster.ts +386 -0
- package/edit/provisioning.cattle.io.cluster/rke2.vue +73 -77
- package/edit/provisioning.cattle.io.cluster/tabs/AddOnAdditionalManifest.vue +45 -0
- package/edit/provisioning.cattle.io.cluster/tabs/AddOnConfig.vue +97 -0
- package/mixins/chart.js +6 -2
- package/models/catalog.cattle.io.app.js +112 -21
- package/models/management.cattle.io.cluster.js +18 -6
- package/package.json +1 -1
- package/pages/c/_cluster/apps/charts/install.vue +2 -1
- package/plugins/dashboard-store/actions.js +3 -2
- package/scripts/extension/bundle +1 -1
- package/scripts/publish-shell.sh +62 -55
- package/scripts/test-plugins-build.sh +111 -29
- package/scripts/typegen.sh +26 -23
- package/store/catalog.js +1 -1
- package/store/features.js +1 -0
- package/store/type-map.utils.ts +44 -0
- package/types/shell/index.d.ts +2 -0
- package/types/store/dashboard-store.types.ts +23 -0
- package/types/store/vuex.d.ts +9 -0
- package/utils/cluster.js +9 -0
- package/utils/v-sphere.ts +277 -0
- package/.DS_Store +0 -0
- package/creators/app/app.package.json +0 -13
- package/creators/app/files/.eslintignore +0 -18
- package/creators/app/files/.eslintrc.js +0 -173
- package/creators/app/files/.gitignore +0 -70
- package/creators/app/files/.vscode/settings.json +0 -22
- package/creators/app/files/babel.config.js +0 -1
- package/creators/app/files/tsconfig.json +0 -42
- package/creators/app/files/vue.config.js +0 -6
- package/creators/app/init +0 -101
- package/creators/app/package.json +0 -25
- package/creators/pkg/files/.github/workflows/build-extension-catalog.yml +0 -28
- package/creators/pkg/files/.github/workflows/build-extension-charts.yml +0 -26
- package/creators/pkg/files/babel.config.js +0 -1
- package/creators/pkg/files/index.ts +0 -14
- package/creators/pkg/files/tsconfig.json +0 -53
- package/creators/pkg/files/vue.config.js +0 -1
- package/creators/pkg/init +0 -254
- package/creators/pkg/package.json +0 -19
- package/creators/pkg/pkg.package.json +0 -21
- package/creators/pkg/vue-shim.ts +0 -4
- package/creators/update/init +0 -56
- package/creators/update/package.json +0 -20
- package/creators/update/upgrade +0 -56
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Banner } from '@components/Banner';
|
|
3
|
+
|
|
4
|
+
import Questions from '@shell/components/Questions';
|
|
5
|
+
import YamlEditor from '@shell/components/YamlEditor';
|
|
6
|
+
import { labelForAddon } from '@shell/utils/cluster';
|
|
7
|
+
import { _EDIT } from '@shell/config/query-params';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
components: {
|
|
11
|
+
Banner,
|
|
12
|
+
Questions,
|
|
13
|
+
YamlEditor
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
props: {
|
|
17
|
+
mode: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
value: {
|
|
22
|
+
type: Object,
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
versionInfo: {
|
|
26
|
+
type: Object,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
addonVersion: {
|
|
30
|
+
type: Object,
|
|
31
|
+
required: false,
|
|
32
|
+
default: null
|
|
33
|
+
},
|
|
34
|
+
addonsRev: {
|
|
35
|
+
type: Number,
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
38
|
+
userChartValuesTemp: {
|
|
39
|
+
type: Object,
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
initYamlEditor: {
|
|
43
|
+
type: Function,
|
|
44
|
+
required: true,
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
data() {
|
|
49
|
+
return { labelForAddon };
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
computed: {
|
|
53
|
+
isEdit() {
|
|
54
|
+
return this.mode === _EDIT;
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<div>
|
|
62
|
+
<Banner
|
|
63
|
+
v-if="isEdit"
|
|
64
|
+
color="warning"
|
|
65
|
+
>
|
|
66
|
+
{{ t('cluster.addOns.dependencyBanner') }}
|
|
67
|
+
</Banner>
|
|
68
|
+
<div
|
|
69
|
+
v-if="versionInfo && addonVersion"
|
|
70
|
+
:key="addonsRev"
|
|
71
|
+
>
|
|
72
|
+
<h3>{{ labelForAddon(addonVersion.name) }}</h3>
|
|
73
|
+
<Questions
|
|
74
|
+
v-if="versionInfo[addonVersion.name] && versionInfo[addonVersion.name].questions && addonVersion.name && userChartValuesTemp[addonVersion.name]"
|
|
75
|
+
v-model="userChartValuesTemp[addonVersion.name]"
|
|
76
|
+
:emit="true"
|
|
77
|
+
in-store="management"
|
|
78
|
+
:mode="mode"
|
|
79
|
+
:tabbed="false"
|
|
80
|
+
:source="versionInfo[addonVersion.name]"
|
|
81
|
+
:target-namespace="value.metadata.namespace"
|
|
82
|
+
@updated="$emit('update-questions', addonVersion.name)"
|
|
83
|
+
/>
|
|
84
|
+
<YamlEditor
|
|
85
|
+
v-else
|
|
86
|
+
ref="yaml-values"
|
|
87
|
+
:value="initYamlEditor(addonVersion.name)"
|
|
88
|
+
:scrolling="true"
|
|
89
|
+
:as-object="true"
|
|
90
|
+
:editor-mode="mode === 'view' ? 'VIEW_CODE' : 'EDIT_CODE'"
|
|
91
|
+
:hide-preview-buttons="true"
|
|
92
|
+
@input="data => $emit('update-values', addonVersion.name, data)"
|
|
93
|
+
/>
|
|
94
|
+
<div class="spacer" />
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
package/mixins/chart.js
CHANGED
|
@@ -263,6 +263,8 @@ export default {
|
|
|
263
263
|
id: `${ this.query.appNamespace }/${ this.query.appName }`,
|
|
264
264
|
});
|
|
265
265
|
|
|
266
|
+
await this.existing?.fetchValues(true);
|
|
267
|
+
|
|
266
268
|
this.mode = _EDIT;
|
|
267
269
|
} catch (e) {
|
|
268
270
|
this.mode = _CREATE;
|
|
@@ -420,10 +422,12 @@ export default {
|
|
|
420
422
|
}
|
|
421
423
|
}
|
|
422
424
|
if (existingCRDApp) {
|
|
425
|
+
await existingCRDApp.fetchValues(true);
|
|
426
|
+
|
|
423
427
|
// spec.values are any non-default values the user configured
|
|
424
428
|
// the installation form should show these, as well as any default values from the chart
|
|
425
|
-
const existingValues = clone(existingCRDApp.
|
|
426
|
-
const defaultValues = clone(existingCRDApp.
|
|
429
|
+
const existingValues = clone(existingCRDApp.values || {});
|
|
430
|
+
const defaultValues = clone(existingCRDApp.chartValues || {});
|
|
427
431
|
|
|
428
432
|
crdVersionInfo.existingValues = existingValues;
|
|
429
433
|
crdVersionInfo.allValues = merge(defaultValues, existingValues);
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import { CATALOG as CATALOG_ANNOTATIONS, FLEET } from '@shell/config/labels-annotations';
|
|
5
5
|
import { compare, isPrerelease, sortable } from '@shell/utils/version';
|
|
6
6
|
import { filterBy } from '@shell/utils/array';
|
|
7
|
-
import { CATALOG, MANAGEMENT, NORMAN } from '@shell/config/types';
|
|
7
|
+
import { CATALOG, MANAGEMENT, NORMAN, SECRET } from '@shell/config/types';
|
|
8
8
|
import { SHOW_PRE_RELEASE } from '@shell/store/prefs';
|
|
9
9
|
import { set } from '@shell/utils/object';
|
|
10
10
|
|
|
@@ -271,28 +271,119 @@ export default class CatalogApp extends SteveModel {
|
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
}
|
|
274
|
+
async deployedAsLegacy() {
|
|
275
|
+
await this.fetchValues();
|
|
276
|
+
|
|
277
|
+
if (this.values?.global) {
|
|
278
|
+
const { clusterName, projectName } = this.values.global;
|
|
279
|
+
|
|
280
|
+
if (clusterName && projectName) {
|
|
281
|
+
try {
|
|
282
|
+
const legacyApp = await this.$dispatch('rancher/find', {
|
|
283
|
+
type: NORMAN.APP,
|
|
284
|
+
id: `${ projectName }:${ this.metadata?.name }`,
|
|
285
|
+
opt: { url: `/v3/project/${ clusterName }:${ projectName }/apps/${ projectName }:${ this.metadata?.name }` }
|
|
286
|
+
}, { root: true });
|
|
287
|
+
|
|
288
|
+
if (legacyApp) {
|
|
289
|
+
return legacyApp;
|
|
290
|
+
}
|
|
291
|
+
} catch (e) {}
|
|
292
292
|
}
|
|
293
|
+
}
|
|
293
294
|
|
|
294
|
-
|
|
295
|
-
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* User and Chart values live in a helm secret, so fetch it (with special param)
|
|
300
|
+
*/
|
|
301
|
+
async fetchValues(force = false) {
|
|
302
|
+
if (!this.secretId) {
|
|
303
|
+
// If there's no secret id this isn't ever going to work, no need to carry on
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const haveValues = !!this._values && !!this._chartValues;
|
|
308
|
+
|
|
309
|
+
if (haveValues && !force) {
|
|
310
|
+
// If we already have the required values and we're not forced to re-fetch, no need to carry on
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
try {
|
|
315
|
+
await this.$dispatch('find', {
|
|
316
|
+
type: SECRET,
|
|
317
|
+
id: this.secretId,
|
|
318
|
+
opt: {
|
|
319
|
+
force: force || (!!this._secret && !haveValues), // force if explicitly requested or there's ean existing secret without the required values we have a secret without the values in (Secret has been fetched another way)
|
|
320
|
+
watch: false, // Cannot watch with custom params (they are dropped on calls made when resyncing over socket)
|
|
321
|
+
params: { includeHelmData: true }
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
} catch (e) {
|
|
325
|
+
console.error(`Cannot find values for ${ this.id } (unable to fetch)`, e); // eslint-disable-line no-console
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
get secretId() {
|
|
330
|
+
const metadata = this.metadata;
|
|
331
|
+
|
|
332
|
+
if (!metadata) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
const secretReference = metadata?.ownerReferences?.find((ow) => ow.kind.toLowerCase() === SECRET);
|
|
336
|
+
|
|
337
|
+
const secretId = secretReference?.name;
|
|
338
|
+
const secretNamespace = metadata.namespace;
|
|
339
|
+
|
|
340
|
+
if (!secretNamespace || !secretId) {
|
|
341
|
+
console.warn(`Cannot find values for ${ this.id } (cannot find related secret namespace or id)`); // eslint-disable-line no-console
|
|
342
|
+
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return `${ secretNamespace }/${ secretId }`;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
get _secret() {
|
|
350
|
+
return this.secretId ? this.$getters['byId'](SECRET, this.secretId) : null;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
_validateSecret(noun) {
|
|
354
|
+
if (this._secret === undefined) {
|
|
355
|
+
throw new Error(`Cannot find ${ noun } for ${ this.id } (chart secret has not been fetched via app \`fetchValues\`)`);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (this._secret === null) {
|
|
359
|
+
throw new Error(`Cannot find ${ noun } for ${ this.id } (chart secret cannot or has failed to fetch) `);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* The user's helm values
|
|
365
|
+
*/
|
|
366
|
+
get values() {
|
|
367
|
+
this._validateSecret('values');
|
|
368
|
+
|
|
369
|
+
return this._values;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
get _values() {
|
|
373
|
+
return this._secret?.data?.release?.config;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* The Charts default helm values
|
|
378
|
+
*/
|
|
379
|
+
get chartValues() {
|
|
380
|
+
this._validateSecret('chartValues');
|
|
381
|
+
|
|
382
|
+
return this._chartValues;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
get _chartValues() {
|
|
386
|
+
return this._secret?.data?.release?.chart?.values;
|
|
296
387
|
}
|
|
297
388
|
}
|
|
298
389
|
|
|
@@ -16,6 +16,8 @@ import { LINUX, WINDOWS } from '@shell/store/catalog';
|
|
|
16
16
|
import { KONTAINER_TO_DRIVER } from './management.cattle.io.kontainerdriver';
|
|
17
17
|
import { PINNED_CLUSTERS } from '@shell/store/prefs';
|
|
18
18
|
|
|
19
|
+
const DEFAULT_BADGE_COLOR = '#707070';
|
|
20
|
+
|
|
19
21
|
// See translation file cluster.providers for list of providers
|
|
20
22
|
// If the logo is not named with the provider name, add an override here
|
|
21
23
|
const PROVIDER_LOGO_OVERRIDE = {};
|
|
@@ -295,20 +297,30 @@ export default class MgmtCluster extends HybridModel {
|
|
|
295
297
|
|
|
296
298
|
// Custom badge to show for the Cluster (if the appropriate annotations are set)
|
|
297
299
|
get badge() {
|
|
298
|
-
const
|
|
300
|
+
const icon = this.metadata?.annotations?.[CLUSTER_BADGE.ICON_TEXT];
|
|
301
|
+
const comment = this.metadata?.annotations?.[CLUSTER_BADGE.TEXT];
|
|
299
302
|
|
|
300
|
-
if (!
|
|
303
|
+
if (!icon && !comment) {
|
|
301
304
|
return undefined;
|
|
302
305
|
}
|
|
303
306
|
|
|
304
|
-
|
|
307
|
+
let color = this.metadata?.annotations[CLUSTER_BADGE.COLOR] || DEFAULT_BADGE_COLOR;
|
|
305
308
|
const iconText = this.metadata?.annotations[CLUSTER_BADGE.ICON_TEXT] || '';
|
|
309
|
+
let foregroundColor;
|
|
310
|
+
|
|
311
|
+
try {
|
|
312
|
+
foregroundColor = textColor(parseColor(color.trim())); // Remove any whitespace
|
|
313
|
+
} catch (_e) {
|
|
314
|
+
// If we could not parse the badge color, use the defaults
|
|
315
|
+
color = DEFAULT_BADGE_COLOR;
|
|
316
|
+
foregroundColor = textColor(parseColor(color));
|
|
317
|
+
}
|
|
306
318
|
|
|
307
319
|
return {
|
|
308
|
-
text,
|
|
320
|
+
text: comment || undefined,
|
|
309
321
|
color,
|
|
310
|
-
textColor:
|
|
311
|
-
iconText: iconText.substr(0,
|
|
322
|
+
textColor: foregroundColor,
|
|
323
|
+
iconText: iconText.substr(0, 3)
|
|
312
324
|
};
|
|
313
325
|
}
|
|
314
326
|
|
package/package.json
CHANGED
|
@@ -301,8 +301,9 @@ export default {
|
|
|
301
301
|
*/
|
|
302
302
|
userValues = diff(this.loadedVersionValues, this.chartValues);
|
|
303
303
|
} else if ( this.existing ) {
|
|
304
|
+
await this.existing.fetchValues(); // In theory this has already been called, but do again to be safe
|
|
304
305
|
/* For an already installed app, use the values from the previous install. */
|
|
305
|
-
userValues = clone(this.existing.
|
|
306
|
+
userValues = clone(this.existing.values || {});
|
|
306
307
|
} else {
|
|
307
308
|
/* For an new app, start empty. */
|
|
308
309
|
userValues = {};
|
|
@@ -8,6 +8,7 @@ import { normalizeType } from './normalize';
|
|
|
8
8
|
import garbageCollect from '@shell/utils/gc/gc';
|
|
9
9
|
import { addSchemaIndexFields } from '@shell/plugins/steve/schema.utils';
|
|
10
10
|
import { addParam } from '@shell/utils/url';
|
|
11
|
+
import { conditionalDepaginate } from '@shell/store/type-map.utils';
|
|
11
12
|
|
|
12
13
|
export const _ALL = 'all';
|
|
13
14
|
export const _MERGE = 'merge';
|
|
@@ -188,7 +189,7 @@ export default {
|
|
|
188
189
|
opt = opt || {};
|
|
189
190
|
opt.url = getters.urlFor(type, null, opt);
|
|
190
191
|
opt.stream = opt.stream !== false && load !== _NONE;
|
|
191
|
-
opt.depaginate = typeOptions?.depaginate;
|
|
192
|
+
opt.depaginate = conditionalDepaginate(typeOptions?.depaginate, { ctx, args: { type, opt } });
|
|
192
193
|
|
|
193
194
|
let skipHaveAll = false;
|
|
194
195
|
|
|
@@ -367,7 +368,7 @@ export default {
|
|
|
367
368
|
opt = opt || {};
|
|
368
369
|
opt.labelSelector = selector;
|
|
369
370
|
opt.url = getters.urlFor(type, null, opt);
|
|
370
|
-
opt.depaginate = typeOptions?.depaginate;
|
|
371
|
+
opt.depaginate = conditionalDepaginate(typeOptions?.depaginate, { ctx, args: { type, opt } });
|
|
371
372
|
|
|
372
373
|
const res = await dispatch('request', { opt, type });
|
|
373
374
|
|
package/scripts/extension/bundle
CHANGED
|
@@ -42,7 +42,7 @@ for d in ${BASE_DIR}/dist-pkg/*; do
|
|
|
42
42
|
mkdir plugin && mv ./${pkg}/* ./plugin
|
|
43
43
|
rm -rf ./${pkg}/* && mv ./plugin ./${pkg}
|
|
44
44
|
|
|
45
|
-
find ${pkg} -type f
|
|
45
|
+
find ${pkg} -type f | sed "s|^${pkg}/||" | sort > ./${pkg}/files.txt
|
|
46
46
|
popd > /dev/null
|
|
47
47
|
|
|
48
48
|
cp -R ${BASE_DIR}/dist-pkg/${pkg} ${TMP}/container/plugin
|
package/scripts/publish-shell.sh
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
|
+
set -eo pipefail
|
|
4
|
+
|
|
3
5
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
|
4
|
-
BASE_DIR="$(
|
|
5
|
-
cd $SCRIPT_DIR && cd ../.. &
|
|
6
|
-
pwd
|
|
7
|
-
)"
|
|
6
|
+
BASE_DIR="$(cd $SCRIPT_DIR && cd ../.. && pwd)"
|
|
8
7
|
SHELL_DIR=$BASE_DIR/shell/
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
CREATORS_DIR=$BASE_DIR/creators/extension
|
|
9
|
+
FORCE_PUBLISH_TO_NPM="false"
|
|
10
|
+
DEFAULT_NPM_REGISTRY="https://registry.npmjs.org"
|
|
11
|
+
|
|
12
|
+
# if TAG doesn't exist, we can exit as it's needed for any type of publish.
|
|
13
|
+
if [ -z "$TAG" ]; then
|
|
14
|
+
echo "You need to set the TAG variable first!"
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
11
17
|
|
|
12
18
|
if [ ! -d "${BASE_DIR}/node_modules" ]; then
|
|
13
19
|
echo "You need to run 'yarn install' first"
|
|
@@ -16,41 +22,30 @@ fi
|
|
|
16
22
|
|
|
17
23
|
echo "Publishing Shell Packages"
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
if [ "$1" == "--npm" ]; then
|
|
26
|
+
FORCE_PUBLISH_TO_NPM="true"
|
|
27
|
+
fi
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
if [ "$FORCE_PUBLISH_TO_NPM" == "true" ]; then
|
|
30
|
+
export NPM_REGISTRY=$DEFAULT_NPM_REGISTRY
|
|
31
|
+
fi
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
mkdir -p ${PKG_DIST}
|
|
27
|
-
rm -rf ${PKG_DIST}/app
|
|
28
|
-
rm -rf ${PKG_DIST}/pkg
|
|
29
|
-
rm -rf ${PKG_DIST}/update
|
|
33
|
+
PUBLISH_ARGS="--no-git-tag-version --access public --registry $NPM_REGISTRY"
|
|
30
34
|
|
|
31
35
|
pushd ${SHELL_DIR} >/dev/null
|
|
32
36
|
|
|
33
|
-
PKG_VERSION=$(node -p "require('./package.json').version")
|
|
34
|
-
popd >/dev/null
|
|
35
|
-
|
|
36
|
-
echo "Publishing version: $PKG_VERSION"
|
|
37
|
-
|
|
38
|
-
cp -R ${SHELL_DIR}/creators/app ${PKG_DIST}
|
|
39
|
-
cp -R ${SHELL_DIR}/creators/pkg ${PKG_DIST}
|
|
40
|
-
cp -R ${SHELL_DIR}/creators/update ${PKG_DIST}
|
|
41
|
-
|
|
42
|
-
sed -i.bak -e "s/\"0.0.0/"\"$PKG_VERSION"/g" ${PKG_DIST}/app/package.json
|
|
43
|
-
sed -i.bak -e "s/\"0.0.0/"\"$PKG_VERSION"/g" ${PKG_DIST}/pkg/package.json
|
|
44
|
-
sed -i.bak -e "s/\"0.0.0/"\"$PKG_VERSION"/g" ${PKG_DIST}/update/package.json
|
|
45
|
-
|
|
46
|
-
rm ${PKG_DIST}/app/package.json.bak
|
|
47
|
-
rm ${PKG_DIST}/pkg/package.json.bak
|
|
48
|
-
rm ${PKG_DIST}/update/package.json.bak
|
|
49
|
-
|
|
50
37
|
function publish() {
|
|
51
38
|
NAME=$1
|
|
52
39
|
FOLDER=$2
|
|
53
40
|
|
|
41
|
+
# if we pass a third arg, that is the version number
|
|
42
|
+
# that we want to actually publish on NPM
|
|
43
|
+
# they should match with the package.json version stated
|
|
44
|
+
# because of the check in the "Check Tags Version Matching" step in the workflow
|
|
45
|
+
if [ -n "$3" ]; then
|
|
46
|
+
PKG_VERSION=$3
|
|
47
|
+
fi
|
|
48
|
+
|
|
54
49
|
echo "Publishing ${NAME} from ${FOLDER}"
|
|
55
50
|
pushd ${FOLDER} >/dev/null
|
|
56
51
|
|
|
@@ -61,25 +56,20 @@ function publish() {
|
|
|
61
56
|
cp -R ${BASE_DIR}/pkg/rancher-components/src/components ./rancher-components/
|
|
62
57
|
fi
|
|
63
58
|
|
|
64
|
-
if
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# Remove index.ts from pkg files, as we don't want to replace that
|
|
71
|
-
rm -f ./pkg/files/index.ts
|
|
72
|
-
|
|
73
|
-
# Update the package.json for the app
|
|
74
|
-
cd app
|
|
75
|
-
node ${SCRIPT_DIR}/record-deps.js
|
|
76
|
-
cd ..
|
|
59
|
+
# if the PKG_VERSION has a - it means it will be a pre-release of legacy-v1
|
|
60
|
+
if [[ $PKG_VERSION == *"-"* ]]; then
|
|
61
|
+
PUBLISH_ARGS="$PUBLISH_ARGS --tag legacy-v1-pre-release"
|
|
62
|
+
else
|
|
63
|
+
# If we need to release shell, we tag it as legacy-v1
|
|
64
|
+
PUBLISH_ARGS="$PUBLISH_ARGS --tag legacy-v1"
|
|
77
65
|
fi
|
|
78
66
|
|
|
79
67
|
# Make a note of dependency versions, if required
|
|
80
68
|
node ${SCRIPT_DIR}/record-deps.js
|
|
81
69
|
|
|
82
|
-
|
|
70
|
+
echo "Publishing to registry: $NPM_REGISTRY with args: $PUBLISH_ARGS"
|
|
71
|
+
|
|
72
|
+
npm publish ${PUBLISH_ARGS}
|
|
83
73
|
RET=$?
|
|
84
74
|
|
|
85
75
|
popd >/dev/null
|
|
@@ -90,15 +80,32 @@ function publish() {
|
|
|
90
80
|
fi
|
|
91
81
|
}
|
|
92
82
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
publish "Application creator" ${PKG_DIST}/app/
|
|
99
|
-
publish "Package creator" ${PKG_DIST}/pkg/
|
|
100
|
-
publish "Update" ${PKG_DIST}/update/
|
|
83
|
+
echo "TAG ${TAG}"
|
|
84
|
+
|
|
85
|
+
# let's get the package name and version from the tag
|
|
86
|
+
PKG_NAME=$(sed 's/-pkg-v.*//' <<< "$TAG")
|
|
87
|
+
PKG_V=$(sed 's/.*-pkg-v//'<<< "$TAG")
|
|
101
88
|
|
|
102
|
-
echo "
|
|
89
|
+
echo "PKG_NAME ${PKG_NAME}"
|
|
90
|
+
echo "PKG_V ${PKG_V}"
|
|
103
91
|
|
|
92
|
+
# Generate the type definitions for the shell
|
|
93
|
+
if [ ${PKG_NAME} == "shell" ]; then
|
|
94
|
+
${SCRIPT_DIR}/typegen.sh
|
|
95
|
+
fi
|
|
104
96
|
|
|
97
|
+
# version comparison checks
|
|
98
|
+
case $PKG_NAME in
|
|
99
|
+
"shell")
|
|
100
|
+
echo "Publishing only Shell pkg via tagged release"
|
|
101
|
+
publish "Shell" ${SHELL_DIR} ${PKG_V}
|
|
102
|
+
;;
|
|
103
|
+
"creators")
|
|
104
|
+
echo "Publishing only Creators pkg via tagged release"
|
|
105
|
+
publish "Extension creator" ${CREATORS_DIR} ${PKG_V}
|
|
106
|
+
;;
|
|
107
|
+
*)
|
|
108
|
+
echo "something went wrong with the tagging name => TAG: ${TAG} , PKG_NAME: ${PKG_NAME}. Admissable names are 'shell' and 'creator'"
|
|
109
|
+
exit 1
|
|
110
|
+
;;
|
|
111
|
+
esac
|