create-piral-instance 1.8.0-beta.7741 → 1.8.0-beta.7746
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/index.js +102 -1
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +121 -2
package/lib/index.js
CHANGED
|
@@ -1,7 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const piral_cli_1 = require("piral-cli");
|
|
4
|
-
|
|
4
|
+
const utils_1 = require("piral-cli/utils");
|
|
5
|
+
const key = 'use-feed';
|
|
6
|
+
const options = {
|
|
7
|
+
empty: 'use default empty feed',
|
|
8
|
+
custom: 'use custom feed specified by URL',
|
|
9
|
+
createOfficial: 'create a new feed on feed.piral.cloud',
|
|
10
|
+
createCustom: 'create a new feed on a custom service',
|
|
11
|
+
};
|
|
12
|
+
const host = {
|
|
13
|
+
current: 'https://feed.piral.cloud',
|
|
14
|
+
};
|
|
15
|
+
const flags = [
|
|
16
|
+
{
|
|
17
|
+
name: key,
|
|
18
|
+
alias: [],
|
|
19
|
+
default: options.empty,
|
|
20
|
+
ignore: true,
|
|
21
|
+
describe: 'Sets the micro frontend feed to use for the new app.',
|
|
22
|
+
required: false,
|
|
23
|
+
type: 'string',
|
|
24
|
+
values: [options.empty, options.custom, options.createOfficial, options.createCustom],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'vars',
|
|
28
|
+
alias: [],
|
|
29
|
+
default: 'https://feed.piral.cloud/api/v1/pilet/empty',
|
|
30
|
+
describe: 'The URL for the custom feed to use.',
|
|
31
|
+
required: false,
|
|
32
|
+
type: 'string',
|
|
33
|
+
convert(answer) {
|
|
34
|
+
return {
|
|
35
|
+
feedUrl: answer,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
when(answers) {
|
|
39
|
+
return answers[key] === options.custom;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'vars',
|
|
44
|
+
alias: [],
|
|
45
|
+
default: `awesome-feed-${~~(Math.random() * 100000)}`,
|
|
46
|
+
describe: 'The name for the custom feed to use.',
|
|
47
|
+
required: false,
|
|
48
|
+
type: 'string',
|
|
49
|
+
async validate(answer) {
|
|
50
|
+
const data = {
|
|
51
|
+
id: answer,
|
|
52
|
+
};
|
|
53
|
+
const result = await (0, utils_1.postData)(`https://feed.piral.cloud/api/v1/feed`, 'none', '', data, { 'content-type': 'application/json' }, undefined, true);
|
|
54
|
+
return result.success;
|
|
55
|
+
},
|
|
56
|
+
convert(answer) {
|
|
57
|
+
return {
|
|
58
|
+
feedUrl: `https://feed.piral.cloud/api/v1/pilet/${answer}`,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
when(answers) {
|
|
62
|
+
return answers[key] === options.createOfficial;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'custom-host',
|
|
67
|
+
alias: [],
|
|
68
|
+
default: host.current,
|
|
69
|
+
describe: 'The host for the custom feed service to use (e.g., https://feed.company.com).',
|
|
70
|
+
required: false,
|
|
71
|
+
ignore: true,
|
|
72
|
+
type: 'string',
|
|
73
|
+
validate(answer) {
|
|
74
|
+
host.current = answer;
|
|
75
|
+
return /^https?:\/\//.test(answer);
|
|
76
|
+
},
|
|
77
|
+
when(answers) {
|
|
78
|
+
return answers[key] === options.createCustom;
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'vars',
|
|
83
|
+
alias: [],
|
|
84
|
+
default: `awesome-feed-${~~(Math.random() * 100000)}`,
|
|
85
|
+
describe: 'The name for the custom feed to use.',
|
|
86
|
+
required: false,
|
|
87
|
+
type: 'string',
|
|
88
|
+
async validate(answer) {
|
|
89
|
+
const data = {
|
|
90
|
+
id: answer,
|
|
91
|
+
};
|
|
92
|
+
const result = await (0, utils_1.postData)(`${host.current}/api/v1/feed`, 'none', '', data, { 'content-type': 'application/json' }, undefined, true);
|
|
93
|
+
return result.success;
|
|
94
|
+
},
|
|
95
|
+
convert(answer) {
|
|
96
|
+
return {
|
|
97
|
+
feedUrl: `${host.current}/api/v1/pilet/${answer}`,
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
when(answers) {
|
|
101
|
+
return answers[key] === options.createCustom;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
(0, piral_cli_1.runQuestionnaire)('new-piral', undefined, flags).then(() => process.exit(0), (err) => {
|
|
5
106
|
err && !err.logged && console.error(err.message);
|
|
6
107
|
console.log('Codes Reference: https://docs.piral.io/code/search');
|
|
7
108
|
process.exit(1);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yCAAmD;AACnD,2CAA2C;AAE3C,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,OAAO,GAAG;IACd,KAAK,EAAE,wBAAwB;IAC/B,MAAM,EAAE,kCAAkC;IAC1C,cAAc,EAAE,uCAAuC;IACvD,YAAY,EAAE,uCAAuC;CACtD,CAAC;AACF,MAAM,IAAI,GAAG;IACX,OAAO,EAAE,0BAA0B;CACpC,CAAC;AAEF,MAAM,KAAK,GAAgB;IACzB;QACE,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,OAAO,CAAC,KAAK;QACtB,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,sDAAsD;QAChE,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,YA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E;IACN,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;IAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-piral-instance",
|
|
3
|
-
"version": "1.8.0-beta.
|
|
3
|
+
"version": "1.8.0-beta.7746",
|
|
4
4
|
"description": "The NPM initializer to scaffold a new Piral instance.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"scaffold",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"inquirer": "^12",
|
|
42
|
-
"piral-cli": "1.8.0-beta.
|
|
42
|
+
"piral-cli": "1.8.0-beta.7746"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "566a8efb70d96d1950435662f8da4ddde6abb906"
|
|
45
45
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,125 @@
|
|
|
1
|
-
import { runQuestionnaire } from 'piral-cli';
|
|
1
|
+
import { Flag, runQuestionnaire } from 'piral-cli';
|
|
2
|
+
import { postData } from 'piral-cli/utils';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const key = 'use-feed';
|
|
5
|
+
const options = {
|
|
6
|
+
empty: 'use default empty feed',
|
|
7
|
+
custom: 'use custom feed specified by URL',
|
|
8
|
+
createOfficial: 'create a new feed on feed.piral.cloud',
|
|
9
|
+
createCustom: 'create a new feed on a custom service',
|
|
10
|
+
};
|
|
11
|
+
const host = {
|
|
12
|
+
current: 'https://feed.piral.cloud',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const flags: Array<Flag> = [
|
|
16
|
+
{
|
|
17
|
+
name: key,
|
|
18
|
+
alias: [],
|
|
19
|
+
default: options.empty,
|
|
20
|
+
ignore: true,
|
|
21
|
+
describe: 'Sets the micro frontend feed to use for the new app.',
|
|
22
|
+
required: false,
|
|
23
|
+
type: 'string',
|
|
24
|
+
values: [options.empty, options.custom, options.createOfficial, options.createCustom],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'vars',
|
|
28
|
+
alias: [],
|
|
29
|
+
default: 'https://feed.piral.cloud/api/v1/pilet/empty',
|
|
30
|
+
describe: 'The URL for the custom feed to use.',
|
|
31
|
+
required: false,
|
|
32
|
+
type: 'string',
|
|
33
|
+
convert(answer) {
|
|
34
|
+
return {
|
|
35
|
+
feedUrl: answer,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
when(answers) {
|
|
39
|
+
return answers[key] === options.custom;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'vars',
|
|
44
|
+
alias: [],
|
|
45
|
+
default: `awesome-feed-${~~(Math.random() * 100000)}`,
|
|
46
|
+
describe: 'The name for the custom feed to use.',
|
|
47
|
+
required: false,
|
|
48
|
+
type: 'string',
|
|
49
|
+
async validate(answer) {
|
|
50
|
+
const data = {
|
|
51
|
+
id: answer,
|
|
52
|
+
};
|
|
53
|
+
const result = await postData(
|
|
54
|
+
`https://feed.piral.cloud/api/v1/feed`,
|
|
55
|
+
'none',
|
|
56
|
+
'',
|
|
57
|
+
data,
|
|
58
|
+
{ 'content-type': 'application/json' },
|
|
59
|
+
undefined,
|
|
60
|
+
true,
|
|
61
|
+
);
|
|
62
|
+
return result.success;
|
|
63
|
+
},
|
|
64
|
+
convert(answer) {
|
|
65
|
+
return {
|
|
66
|
+
feedUrl: `https://feed.piral.cloud/api/v1/pilet/${answer}`,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
when(answers) {
|
|
70
|
+
return answers[key] === options.createOfficial;
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'custom-host',
|
|
75
|
+
alias: [],
|
|
76
|
+
default: host.current,
|
|
77
|
+
describe: 'The host for the custom feed service to use (e.g., https://feed.company.com).',
|
|
78
|
+
required: false,
|
|
79
|
+
ignore: true,
|
|
80
|
+
type: 'string',
|
|
81
|
+
validate(answer) {
|
|
82
|
+
host.current = answer;
|
|
83
|
+
return /^https?:\/\//.test(answer);
|
|
84
|
+
},
|
|
85
|
+
when(answers) {
|
|
86
|
+
return answers[key] === options.createCustom;
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'vars',
|
|
91
|
+
alias: [],
|
|
92
|
+
default: `awesome-feed-${~~(Math.random() * 100000)}`,
|
|
93
|
+
describe: 'The name for the custom feed to use.',
|
|
94
|
+
required: false,
|
|
95
|
+
type: 'string',
|
|
96
|
+
async validate(answer) {
|
|
97
|
+
const data = {
|
|
98
|
+
id: answer,
|
|
99
|
+
};
|
|
100
|
+
const result = await postData(
|
|
101
|
+
`${host.current}/api/v1/feed`,
|
|
102
|
+
'none',
|
|
103
|
+
'',
|
|
104
|
+
data,
|
|
105
|
+
{ 'content-type': 'application/json' },
|
|
106
|
+
undefined,
|
|
107
|
+
true,
|
|
108
|
+
);
|
|
109
|
+
return result.success;
|
|
110
|
+
},
|
|
111
|
+
convert(answer) {
|
|
112
|
+
return {
|
|
113
|
+
feedUrl: `${host.current}/api/v1/pilet/${answer}`,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
when(answers) {
|
|
117
|
+
return answers[key] === options.createCustom;
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
runQuestionnaire('new-piral', undefined, flags).then(
|
|
4
123
|
() => process.exit(0),
|
|
5
124
|
(err) => {
|
|
6
125
|
err && !err.logged && console.error(err.message);
|