@twilio/create-flex-plugin 5.0.1-beta.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/LICENSE +21 -0
- package/README.md +132 -0
- package/bin/create-flex-plugin +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/cli.d.ts +26 -0
- package/dist/lib/cli.js +128 -0
- package/dist/lib/cli.js.map +1 -0
- package/dist/lib/commands.d.ts +22 -0
- package/dist/lib/commands.js +128 -0
- package/dist/lib/commands.js.map +1 -0
- package/dist/lib/create-flex-plugin.d.ts +28 -0
- package/dist/lib/create-flex-plugin.js +176 -0
- package/dist/lib/create-flex-plugin.js.map +1 -0
- package/dist/prints/finalMessage.d.ts +7 -0
- package/dist/prints/finalMessage.js +20 -0
- package/dist/prints/finalMessage.js.map +1 -0
- package/dist/utils/github.d.ts +77 -0
- package/dist/utils/github.js +222 -0
- package/dist/utils/github.js.map +1 -0
- package/dist/utils/validators.d.ts +19 -0
- package/dist/utils/validators.js +103 -0
- package/dist/utils/validators.js.map +1 -0
- package/package.json +58 -0
- package/templates/core/README.md +31 -0
- package/templates/core/_.gitignore +66 -0
- package/templates/core/jest.config.js +8 -0
- package/templates/core/public/appConfig.example.js +9 -0
- package/templates/core/public/appConfig.js +7 -0
- package/templates/core/webpack.config.js +8 -0
- package/templates/core/webpack.dev.js +8 -0
- package/templates/js/package.json +18 -0
- package/templates/js/src/DemoPlugin.js +43 -0
- package/templates/js/src/components/CustomTaskList/CustomTaskList.Container.js +15 -0
- package/templates/js/src/components/CustomTaskList/CustomTaskList.Styles.js +14 -0
- package/templates/js/src/components/CustomTaskList/CustomTaskList.jsx +29 -0
- package/templates/js/src/components/__tests__/CustomTaskListComponent.spec.jsx +15 -0
- package/templates/js/src/index.js +5 -0
- package/templates/js/src/states/CustomTaskListState.js +24 -0
- package/templates/js/src/states/index.js +11 -0
- package/templates/ts/package.json +19 -0
- package/templates/ts/src/DemoPlugin.tsx +43 -0
- package/templates/ts/src/components/CustomTaskList/CustomTaskList.Container.ts +24 -0
- package/templates/ts/src/components/CustomTaskList/CustomTaskList.Styles.ts +14 -0
- package/templates/ts/src/components/CustomTaskList/CustomTaskList.tsx +31 -0
- package/templates/ts/src/components/__tests__/CustomTaskListComponent.spec.tsx +15 -0
- package/templates/ts/src/index.ts +5 -0
- package/templates/ts/src/states/CustomTaskListState.ts +30 -0
- package/templates/ts/src/states/index.ts +26 -0
- package/templates/ts/tsconfig.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2018, Twilio, Inc. <help@twilio.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
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/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/create-flex-plugin)
|
|
2
|
+
[](https://www.npmjs.com/package/create-flex-plugin)
|
|
3
|
+
[](../../LICENSE)
|
|
4
|
+
|
|
5
|
+
# Create Flex Plugin
|
|
6
|
+
|
|
7
|
+
Command-line tool to create, develop and build a new Twilio Flex Plugin.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
There is a variety of ways to use/install. The quickest way is:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm init flex-plugin plugin-demo
|
|
15
|
+
cd plugin-demo
|
|
16
|
+
npm start
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### How to install/run using `npm`
|
|
20
|
+
|
|
21
|
+
#### Using `npm`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Via npm init
|
|
25
|
+
npm init flex-plugin plugin-demo
|
|
26
|
+
|
|
27
|
+
# Via npx
|
|
28
|
+
npx create-flex-plugin plugin-demo
|
|
29
|
+
|
|
30
|
+
# Install globally
|
|
31
|
+
npm install -g create-flex-plugin
|
|
32
|
+
create-flex-plugin plugin-demo
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### Using `yarn`:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Via npm init
|
|
39
|
+
npm init flex-plugin plugin-demo --yarn
|
|
40
|
+
|
|
41
|
+
# Via npx
|
|
42
|
+
npx create-flex-plugin plugin-demo --yarn
|
|
43
|
+
|
|
44
|
+
# Install globally
|
|
45
|
+
npm install -g create-flex-plugin
|
|
46
|
+
create-flex-plugin plugin-demo --yarn
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
_Note_: Support for `yarn` only exists for `@twilio/flex-ui > 1.18.0`. If you are upgrading from an older version of the plugin-builder, you'll need to add add `react-emotion` and pin it to `9.2.6`.
|
|
50
|
+
|
|
51
|
+
### Command line arguments:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
create-flex-plugin <name>
|
|
55
|
+
|
|
56
|
+
Creates a new Twilio Flex Plugin project
|
|
57
|
+
|
|
58
|
+
Arguments:
|
|
59
|
+
name Name of your plugin. Needs to start with `plugin-`
|
|
60
|
+
|
|
61
|
+
Options:
|
|
62
|
+
--accountSid, -a The Account SID for your Flex Project
|
|
63
|
+
--runtimeUrl, -r The URL to your Twilio Flex Runtime
|
|
64
|
+
--template, -t A GitHub URL that contains your template
|
|
65
|
+
--typescript, -s Create a typescript project
|
|
66
|
+
--install Auto-install dependencies [boolean] [default: false]
|
|
67
|
+
--yarn, -y Use yarn
|
|
68
|
+
-h, --help Show help [boolean] [default: false]
|
|
69
|
+
-v, --version Show version number [boolean] [default: false]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Creating a Plugin from Custom Template
|
|
73
|
+
|
|
74
|
+
When creating a new plugin, you may provide a `--template` URL to a GitHub repo containing the source code of a Flex plugin. Create Flex Plugin will copy over the entire content from the directory, including all scripts, files and directories that are not part of the src folder. The repo has to be a valid node repository which means that it expects files such as `package.json`, `.gitignore`, `README.md`, etc to be present.
|
|
75
|
+
|
|
76
|
+
#### Template Directory Hierarchy
|
|
77
|
+
|
|
78
|
+
Your GitHub project should be
|
|
79
|
+
```
|
|
80
|
+
/
|
|
81
|
+
src/
|
|
82
|
+
index.js
|
|
83
|
+
...
|
|
84
|
+
...
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Create Flex Plugin will copy over the content from the directory, and expects an `index.js` in the src folder. We will also provide a `public/` folder and a `package.json` but you may override these by including them in your base GitHub repo.
|
|
88
|
+
|
|
89
|
+
See [flex-plugin-template-sample](https://github.com/ktalebian/flex-plugin-template-sample) for a basic example and
|
|
90
|
+
[plugin-agent-autoresponse](github.com/johnfischelli/plugin-agent-autoresponse) for a more complete example.
|
|
91
|
+
|
|
92
|
+
#### Version Support
|
|
93
|
+
|
|
94
|
+
The `--template` link can contain a reference, which can be a `tag` or a `branch` name. For example
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
create-flex-plugin <plugin-name> --template https://github.com/ktalebian/flex-plugin-template-sample/tree/1.0.0
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
would use the tagged version `1.0.0`, while
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
create-flex-plugin <plugin-name> --template https://github.com/ktalebian/flex-plugin-template-sample/tree/master
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
would use the `master` branch.
|
|
107
|
+
|
|
108
|
+
## Contributing
|
|
109
|
+
|
|
110
|
+
Make sure to follow the instructions in the [main repository](https://github.com/twilio/flex-plugin-builder#contributing) to set up the project.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Install dependencies and link local packages with each other
|
|
114
|
+
cd packages/create-flex-plugin
|
|
115
|
+
npx lerna bootstrap
|
|
116
|
+
|
|
117
|
+
# Run tests
|
|
118
|
+
npm test
|
|
119
|
+
|
|
120
|
+
# To execute your local version the CLI
|
|
121
|
+
npm link
|
|
122
|
+
create-flex-plugin --help
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Contributors
|
|
126
|
+
|
|
127
|
+
Thank you to all the lovely contributors to this project. Please check the main repository to see [all contributors](https://github.com/twilio/flex-plugin-builder#contributors).
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
[MIT](../../LICENSE)
|
|
132
|
+
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CreateFlexPlugin = exports.default = void 0;
|
|
7
|
+
/* eslint-disable import/no-unused-modules */
|
|
8
|
+
var updateNotifier_1 = require("@twilio/flex-dev-utils/dist/updateNotifier");
|
|
9
|
+
updateNotifier_1.checkForUpdate();
|
|
10
|
+
var cli_1 = require("./lib/cli");
|
|
11
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(cli_1).default; } });
|
|
12
|
+
var create_flex_plugin_1 = require("./lib/create-flex-plugin");
|
|
13
|
+
Object.defineProperty(exports, "CreateFlexPlugin", { enumerable: true, get: function () { return __importDefault(create_flex_plugin_1).default; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA6C;AAC7C,6EAA4E;AAE5E,+BAAc,EAAE,CAAC;AAEjB,iCAAoC;AAA3B,+GAAA,OAAO,OAAA;AAChB,+DAAuE;AAA9D,uIAAA,OAAO,OAAoB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Options } from 'yargs';
|
|
2
|
+
export interface CLIArguments {
|
|
3
|
+
accountSid?: string;
|
|
4
|
+
a?: string;
|
|
5
|
+
runtimeUrl?: string;
|
|
6
|
+
r?: string;
|
|
7
|
+
install?: boolean;
|
|
8
|
+
i?: boolean;
|
|
9
|
+
name?: string;
|
|
10
|
+
yarn?: boolean;
|
|
11
|
+
y?: boolean;
|
|
12
|
+
template?: string;
|
|
13
|
+
t?: string;
|
|
14
|
+
typescript?: boolean;
|
|
15
|
+
s?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export default class CLI {
|
|
18
|
+
static description: string;
|
|
19
|
+
static flags: {
|
|
20
|
+
[key: string]: Options;
|
|
21
|
+
};
|
|
22
|
+
private readonly parser;
|
|
23
|
+
constructor(cwd?: string);
|
|
24
|
+
parse: (...args: string[]) => Promise<void>;
|
|
25
|
+
private init;
|
|
26
|
+
}
|
package/dist/lib/cli.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var yargs_1 = __importDefault(require("yargs"));
|
|
43
|
+
var flex_dev_utils_1 = require("@twilio/flex-dev-utils");
|
|
44
|
+
var create_flex_plugin_1 = require("./create-flex-plugin");
|
|
45
|
+
var usage = flex_dev_utils_1.multilineString('Creates a new Twilio Flex Plugin project', '', 'Arguments:', 'name\tName of your plugin.');
|
|
46
|
+
var CLI = /** @class */ (function () {
|
|
47
|
+
function CLI(cwd) {
|
|
48
|
+
var _this = this;
|
|
49
|
+
this.parse = function () {
|
|
50
|
+
var args = [];
|
|
51
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
52
|
+
args[_i] = arguments[_i];
|
|
53
|
+
}
|
|
54
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
55
|
+
var argv;
|
|
56
|
+
var _this = this;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
argv = this.parser.parse(args);
|
|
61
|
+
return [4 /*yield*/, flex_dev_utils_1.runner(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
62
|
+
return [2 /*return*/, create_flex_plugin_1.createFlexPlugin(argv)];
|
|
63
|
+
}); }); })];
|
|
64
|
+
case 1:
|
|
65
|
+
_a.sent();
|
|
66
|
+
flex_dev_utils_1.exit(0);
|
|
67
|
+
return [2 /*return*/];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
this.init = function () {
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
_this.parser.usage('$0 <name>', usage, CLI.flags);
|
|
75
|
+
};
|
|
76
|
+
this.parser = yargs_1.default([], cwd);
|
|
77
|
+
this.init();
|
|
78
|
+
}
|
|
79
|
+
CLI.description = usage;
|
|
80
|
+
CLI.flags = {
|
|
81
|
+
typescript: {
|
|
82
|
+
alias: 's',
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
describe: 'Create a TypeScript project',
|
|
85
|
+
default: false,
|
|
86
|
+
},
|
|
87
|
+
template: {
|
|
88
|
+
alias: 't',
|
|
89
|
+
type: 'string',
|
|
90
|
+
describe: 'A GitHub URL that contains your template',
|
|
91
|
+
default: '',
|
|
92
|
+
},
|
|
93
|
+
accountSid: {
|
|
94
|
+
alias: 'a',
|
|
95
|
+
type: 'string',
|
|
96
|
+
describe: 'The Account SID for your Flex Project',
|
|
97
|
+
default: '',
|
|
98
|
+
},
|
|
99
|
+
runtimeUrl: {
|
|
100
|
+
alias: 'r',
|
|
101
|
+
type: 'boolean',
|
|
102
|
+
default: false,
|
|
103
|
+
describe: 'The URL to your Twilio Flex Runtime',
|
|
104
|
+
},
|
|
105
|
+
install: {
|
|
106
|
+
alias: 'i',
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
default: false,
|
|
109
|
+
describe: 'Auto-install dependencies',
|
|
110
|
+
},
|
|
111
|
+
yarn: {
|
|
112
|
+
alias: 'y',
|
|
113
|
+
type: 'boolean',
|
|
114
|
+
default: false,
|
|
115
|
+
describe: 'Use yarn as your dependency manager',
|
|
116
|
+
},
|
|
117
|
+
help: {
|
|
118
|
+
alias: 'h',
|
|
119
|
+
description: usage,
|
|
120
|
+
},
|
|
121
|
+
version: {
|
|
122
|
+
alias: 'v',
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
return CLI;
|
|
126
|
+
}());
|
|
127
|
+
exports.default = CLI;
|
|
128
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/lib/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA6C;AAC7C,yDAAuE;AAEvE,2DAA6E;AAE7E,IAAM,KAAK,GAAG,gCAAe,CAC3B,0CAA0C,EAC1C,EAAE,EACF,YAAY,EACZ,4BAA4B,CAC7B,CAAC;AAkBF;IAmDE,aAAY,GAAY;QAAxB,iBAIC;QAEM,UAAK,GAAG;YAAO,cAAiB;iBAAjB,UAAiB,EAAjB,qBAAiB,EAAjB,IAAiB;gBAAjB,yBAAiB;;;;;;;;4BAC/B,IAAI,GAAiB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;4BAEnD,qBAAM,uBAAM,CAAC;oCAAY,sBAAA,qCAAgB,CAAC,IAA2B,CAAC,EAAA;yCAAA,CAAC,EAAA;;4BAAvE,SAAuE,CAAC;4BACxE,qBAAI,CAAC,CAAC,CAAC,CAAC;;;;;SACT,CAAC;QAEM,SAAI,GAAG;YACb,8DAA8D;YAC9D,KAAI,CAAC,MAAM,CAAC,KAAK,CAAM,WAAW,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACxD,CAAC,CAAC;QAfA,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,EAAE,EAAE,GAAG,CAAuB,CAAC;QAEnD,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAtDa,eAAW,GAAG,KAAK,CAAC;IAEpB,SAAK,GAA+B;QAChD,UAAU,EAAE;YACV,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,6BAA6B;YACvC,OAAO,EAAE,KAAK;SACf;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,0CAA0C;YACpD,OAAO,EAAE,EAAE;SACZ;QACD,UAAU,EAAE;YACV,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,uCAAuC;YACjD,OAAO,EAAE,EAAE;SACZ;QACD,UAAU,EAAE;YACV,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,qCAAqC;SAChD;QACD,OAAO,EAAE;YACP,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,2BAA2B;SACtC;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,qCAAqC;SAChD;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,KAAK;SACnB;QACD,OAAO,EAAE;YACP,KAAK,EAAE,GAAG;SACX;KACF,CAAC;IAqBJ,UAAC;CAAA,AApED,IAoEC;kBApEoB,GAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FlexPluginArguments } from './create-flex-plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Install dependencies
|
|
4
|
+
*
|
|
5
|
+
* @param config {FlexPluginArguments} the plugin argument
|
|
6
|
+
* @return {string} the stdout of the execution
|
|
7
|
+
*/
|
|
8
|
+
export declare const installDependencies: (config: FlexPluginArguments) => Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Appends className to the configuration
|
|
11
|
+
*
|
|
12
|
+
* @param config {FlexPluginArguments} the plugin configuration
|
|
13
|
+
* @return {FlexPluginArguments} the updated configuration
|
|
14
|
+
*/
|
|
15
|
+
export declare const setupConfiguration: (config: FlexPluginArguments) => FlexPluginArguments;
|
|
16
|
+
/**
|
|
17
|
+
* Downloads content from GitHub
|
|
18
|
+
*
|
|
19
|
+
* @param url {string} the GitHub url
|
|
20
|
+
* @param dir {string} the temp directory to save the downloaded file to
|
|
21
|
+
*/
|
|
22
|
+
export declare const downloadFromGitHub: (url: string, dir: string) => Promise<void>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
+
function step(op) {
|
|
35
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
+
while (_) try {
|
|
37
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
38
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
+
switch (op[0]) {
|
|
40
|
+
case 0: case 1: t = op; break;
|
|
41
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
+
default:
|
|
45
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
+
if (t[2]) _.ops.pop();
|
|
50
|
+
_.trys.pop(); continue;
|
|
51
|
+
}
|
|
52
|
+
op = body.call(thisArg, _);
|
|
53
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
exports.downloadFromGitHub = exports.setupConfiguration = exports.installDependencies = void 0;
|
|
59
|
+
var fs_1 = require("@twilio/flex-dev-utils/dist/fs");
|
|
60
|
+
var spawn_1 = require("@twilio/flex-dev-utils/dist/spawn");
|
|
61
|
+
var lodash_1 = require("@twilio/flex-dev-utils/dist/lodash");
|
|
62
|
+
var github = __importStar(require("../utils/github"));
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, global-require, @typescript-eslint/no-require-imports
|
|
64
|
+
var pkg = require(fs_1.findUp(__filename, 'package.json'));
|
|
65
|
+
/**
|
|
66
|
+
* Install dependencies
|
|
67
|
+
*
|
|
68
|
+
* @param config {FlexPluginArguments} the plugin argument
|
|
69
|
+
* @return {string} the stdout of the execution
|
|
70
|
+
*/
|
|
71
|
+
var installDependencies = function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var shellCmd, args, options, _a, stdout, exitCode, stderr;
|
|
73
|
+
return __generator(this, function (_b) {
|
|
74
|
+
switch (_b.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
shellCmd = config.yarn ? 'yarn' : 'npm';
|
|
77
|
+
args = ['install'];
|
|
78
|
+
options = {
|
|
79
|
+
cwd: config.targetDirectory,
|
|
80
|
+
shell: process.env.SHELL,
|
|
81
|
+
};
|
|
82
|
+
return [4 /*yield*/, spawn_1.spawn(shellCmd, args, options)];
|
|
83
|
+
case 1:
|
|
84
|
+
_a = _b.sent(), stdout = _a.stdout, exitCode = _a.exitCode, stderr = _a.stderr;
|
|
85
|
+
if (exitCode === 1) {
|
|
86
|
+
throw new Error(stderr);
|
|
87
|
+
}
|
|
88
|
+
return [2 /*return*/, stdout];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}); };
|
|
92
|
+
exports.installDependencies = installDependencies;
|
|
93
|
+
/**
|
|
94
|
+
* Appends className to the configuration
|
|
95
|
+
*
|
|
96
|
+
* @param config {FlexPluginArguments} the plugin configuration
|
|
97
|
+
* @return {FlexPluginArguments} the updated configuration
|
|
98
|
+
*/
|
|
99
|
+
var setupConfiguration = function (config) {
|
|
100
|
+
var name = config.name || '';
|
|
101
|
+
config.pluginClassName = lodash_1.upperFirst(lodash_1.camelCase(name)).replace('Plugin', '') + "Plugin";
|
|
102
|
+
config.pluginNamespace = name.toLowerCase().replace('plugin-', '');
|
|
103
|
+
config.runtimeUrl = config.runtimeUrl || 'http://localhost:3000';
|
|
104
|
+
config.targetDirectory = fs_1.resolveCwd(name);
|
|
105
|
+
config.flexSdkVersion = pkg.devDependencies['@twilio/flex-ui'];
|
|
106
|
+
config.pluginScriptsVersion = pkg.devDependencies['@twilio/flex-plugin-scripts'];
|
|
107
|
+
return config;
|
|
108
|
+
};
|
|
109
|
+
exports.setupConfiguration = setupConfiguration;
|
|
110
|
+
/**
|
|
111
|
+
* Downloads content from GitHub
|
|
112
|
+
*
|
|
113
|
+
* @param url {string} the GitHub url
|
|
114
|
+
* @param dir {string} the temp directory to save the downloaded file to
|
|
115
|
+
*/
|
|
116
|
+
var downloadFromGitHub = function (url, dir) { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
|
+
var info;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0: return [4 /*yield*/, github.parseGitHubUrl(url)];
|
|
121
|
+
case 1:
|
|
122
|
+
info = _a.sent();
|
|
123
|
+
return [2 /*return*/, github.downloadRepo(info, dir)];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}); };
|
|
127
|
+
exports.downloadFromGitHub = downloadFromGitHub;
|
|
128
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/lib/commands.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAoE;AACpE,2DAA0D;AAC1D,6DAA2E;AAE3E,sDAA0C;AAG1C,qHAAqH;AACrH,IAAM,GAAG,GAAG,OAAO,CAAC,WAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;AAExD;;;;;GAKG;AACI,IAAM,mBAAmB,GAAG,UAAO,MAA2B;;;;;gBAC7D,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;gBACxC,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;gBACnB,OAAO,GAAG;oBACd,GAAG,EAAE,MAAM,CAAC,eAAe;oBAC3B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK;iBACzB,CAAC;gBAEmC,qBAAM,aAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,EAAA;;gBAAnE,KAA+B,SAAoC,EAAjE,MAAM,YAAA,EAAE,QAAQ,cAAA,EAAE,MAAM,YAAA;gBAEhC,IAAI,QAAQ,KAAK,CAAC,EAAE;oBAClB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;iBACzB;gBAED,sBAAO,MAAM,EAAC;;;KACf,CAAC;AAfW,QAAA,mBAAmB,uBAe9B;AAEF;;;;;GAKG;AACI,IAAM,kBAAkB,GAAG,UAAC,MAA2B;IAC5D,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;IAE/B,MAAM,CAAC,eAAe,GAAM,mBAAU,CAAC,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,WAAQ,CAAC;IACtF,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,uBAAuB,CAAC;IACjE,MAAM,CAAC,eAAe,GAAG,eAAU,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,cAAc,GAAG,GAAG,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,CAAC,oBAAoB,GAAG,GAAG,CAAC,eAAe,CAAC,6BAA6B,CAAC,CAAC;IAEjF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B;AAEF;;;;;GAKG;AACI,IAAM,kBAAkB,GAAG,UAAO,GAAW,EAAE,GAAW;;;;oBAClD,qBAAM,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAA;;gBAAvC,IAAI,GAAG,SAAgC;gBAE7C,sBAAO,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,EAAC;;;KACvC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CLIArguments } from './cli';
|
|
2
|
+
export interface FlexPluginArguments extends CLIArguments {
|
|
3
|
+
name: string;
|
|
4
|
+
targetDirectory: string;
|
|
5
|
+
flexSdkVersion: string;
|
|
6
|
+
pluginScriptsVersion: string;
|
|
7
|
+
pluginClassName: string;
|
|
8
|
+
pluginNamespace: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Runs the NPM Installation
|
|
12
|
+
* @param config {FlexPluginArguments} the configuration
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
export declare const _install: (config: FlexPluginArguments) => Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates all the directories and copies the templates over
|
|
18
|
+
*
|
|
19
|
+
* @param config {FlexPluginArguments} the configuration
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
export declare const _scaffold: (config: FlexPluginArguments) => Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a Flex Plugin from the {@link FlexPluginArguments}
|
|
25
|
+
* @param config {FlexPluginArguments} the configuration
|
|
26
|
+
*/
|
|
27
|
+
export declare const createFlexPlugin: (config: FlexPluginArguments) => Promise<void>;
|
|
28
|
+
export default createFlexPlugin;
|