ember-cli 7.4.0-alpha.1 → 7.4.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +57 -80
  2. package/RELEASE.md +10 -1
  3. package/docs/build/data.json +1 -1
  4. package/package.json +24 -32
  5. package/packages/addon-blueprint/files/README.md +1 -1
  6. package/packages/addon-blueprint/package.json +3 -11
  7. package/packages/app-blueprint/files/package.json +16 -16
  8. package/packages/app-blueprint/package.json +2 -10
  9. package/packages/blueprint-blueprint/files/blueprints/__name__/files/.gitkeep +0 -0
  10. package/packages/blueprint-blueprint/files/blueprints/__name__/index.js +0 -16
  11. package/packages/blueprint-blueprint/index.js +0 -5
  12. package/packages/blueprint-blueprint/package.json +0 -13
  13. package/packages/blueprint-model/index.js +0 -1791
  14. package/packages/blueprint-model/node_modules/.bin/markdown-it +0 -21
  15. package/packages/blueprint-model/package.json +0 -31
  16. package/packages/blueprint-model/utilities/clean-remove.js +0 -31
  17. package/packages/blueprint-model/utilities/directory-for-package-name.js +0 -31
  18. package/packages/blueprint-model/utilities/edit-file-diff.js +0 -64
  19. package/packages/blueprint-model/utilities/experiments.js +0 -63
  20. package/packages/blueprint-model/utilities/file-info.js +0 -170
  21. package/packages/blueprint-model/utilities/insert-into-file.js +0 -125
  22. package/packages/blueprint-model/utilities/is-addon.js +0 -5
  23. package/packages/blueprint-model/utilities/markdown-color.js +0 -208
  24. package/packages/blueprint-model/utilities/open-editor.js +0 -44
  25. package/packages/blueprint-model/utilities/prepend-emoji.js +0 -12
  26. package/packages/blueprint-model/utilities/print-command.js +0 -102
  27. package/packages/blueprint-model/utilities/process-template.js +0 -10
  28. package/packages/blueprint-model/utilities/sequence.js +0 -42
  29. package/packages/blueprint-model/utilities/walk-up-path.js +0 -23
@@ -1,208 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
-
5
- const { default: chalk } = require('chalk');
6
- const SilentError = require('silent-error');
7
- const merge = require('lodash/merge');
8
-
9
- let colors = ['red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'black', 'white', 'grey', 'gray'];
10
- let backgroundColors = ['bgRed', 'bgGreen', 'bgBlue', 'bgCyan', 'bgMagenta', 'bgYellow', 'bgWhite', 'bgBlack'];
11
-
12
- /*
13
- Parses markdown and applies coloring to output by matching defined tokens and
14
- applying styling. Default outputs chalk.js coloring for terminal output.
15
- Options:
16
- tokens: pass additional tokens in the following format:
17
- {
18
- name:{
19
- token: '(Reserved)', // example of token
20
- pattern: /(Reserved)/g, // regexp pattern
21
- render(string) { return string + '!'} // function that takes and returns a string
22
- }
23
- }
24
-
25
- markdownOptions: object containing options to pass (or override) to markdown-it-terminal upon
26
- instantiation. See https://github.com/trabus/markdown-it-terminal/blob/master/index.js#L8
27
-
28
- renderStyles: pass an object to render color styles, default is chalk.js
29
-
30
- @class MarkdownColor
31
- @constructor
32
- @param {Object} [options]
33
- */
34
- class MarkdownColor {
35
- constructor(options) {
36
- let optionTokens = (options && options.tokens) || {};
37
- let renderStyles = (options && options.renderStyles) || chalk;
38
- let tokens = this.generateTokens(renderStyles);
39
- let markdownOptions = (options && options.markdownOptions) || {};
40
- const markdown = require('markdown-it');
41
- const terminal = require('markdown-it-terminal');
42
- this.options = options || {};
43
- this.markdown = markdown().use(terminal, markdownOptions);
44
- this.tokens = merge(tokens, optionTokens);
45
- }
46
-
47
- /*
48
- Lookup markdown file and render contents
49
- @method renderFile
50
- @param {String} [filePath]
51
- @param {Object} [options]
52
- */
53
- renderFile(filePath, options) {
54
- let file;
55
- try {
56
- file = fs.readFileSync(filePath, 'utf-8');
57
- } catch (e) {
58
- throw new SilentError(`The file '${filePath}' doesn't exist. Please check your filePath`);
59
- }
60
-
61
- return this.render(file, options);
62
- }
63
-
64
- /*
65
- Parse markdown and output as string
66
- @method render
67
- @param {String} [string]
68
- @param {Object} [options]
69
- @return {String}
70
- */
71
- render(string, options) {
72
- let indent = (options && options.indent) || '';
73
- let input = this.markdown.render(string);
74
- let styles = Object.keys(this.tokens);
75
-
76
- input = input.replace(/^/gm, indent);
77
- styles.reverse().map((style) => {
78
- input = input.replace(this.tokens[style].pattern, this.tokens[style].render);
79
- });
80
- input = input.replace(/~\^(.*)~\^/g, escapeToken);
81
- return input;
82
- }
83
-
84
- /*
85
- Generate default style tokens
86
- @method generateTokens
87
- @return {Object}
88
- */
89
- generateTokens(renderer) {
90
- let defaultTokens = {
91
- // ember-cli styles
92
- option: {
93
- name: 'option',
94
- token: '--option',
95
- pattern: /((--\w*\b)|(<options>))/g,
96
- render: this.renderStylesFactory(renderer, 'cyan'),
97
- },
98
- default: {
99
- name: 'default',
100
- token: '(Default: default)',
101
- pattern: /(\(Default:\s.*\))/g,
102
- render: this.renderStylesFactory(renderer, 'cyan'),
103
- },
104
- required: {
105
- name: 'required',
106
- token: '(Required)',
107
- pattern: /(\(Required\))/g,
108
- render: this.renderStylesFactory(renderer, 'cyan'),
109
- },
110
- };
111
- let colorTokens = unshiftValue(colors.concat(backgroundColors).map(getToken.bind(this)), {}).reduce(setToken);
112
- return merge(colorTokens, defaultTokens);
113
- }
114
-
115
- /*
116
- Looks up multiple styles to apply to the rendered output
117
- @method renderStylesFactory
118
- @param {Object} [renderer] should match chalk.js format
119
- @param {String, Array} [styleNames]
120
- @return {Function} Function that will wrap the input string with styling
121
- */
122
- renderStylesFactory(renderer, styleNames) {
123
- let styles;
124
-
125
- if (Array.isArray(styleNames)) {
126
- styles = styleNames.map(checkStyleName.bind(null, renderer));
127
- } else {
128
- styles = [checkStyleName(renderer, styleNames)];
129
- }
130
-
131
- return function (match, pattern) {
132
- return styles.reverse().reduce((previous, current) => renderer[current](previous), pattern);
133
- };
134
- }
135
- }
136
-
137
- module.exports = MarkdownColor;
138
-
139
- /*
140
- Check to see if style exists on the renderer
141
- @param {Object} [renderer] should match chalk.js format
142
- @param {String} [name]
143
- */
144
- function checkStyleName(renderer, name) {
145
- if (typeof renderer[name] === 'function') {
146
- return name;
147
- } else {
148
- throw new SilentError(`The style '${name}' is not supported by the markdown renderer.`);
149
- }
150
- }
151
-
152
- /*
153
- @param {String} [name]
154
- @param {Object} [options]
155
- @return {RegExp} Returns lookup pattern
156
- */
157
- function getColorTokenRegex(name, options) {
158
- options = options || {};
159
- let start = options.start || '(?:<';
160
- let end = options.end || '>)';
161
- let close = options.close || '(?:</';
162
- let middle = options.middle || '(.*?)';
163
- let tag = start + name + end;
164
- let closeTag = close + name + end;
165
- let pattern = tag + middle + closeTag;
166
- return new RegExp(pattern, 'g');
167
- }
168
-
169
- /*
170
- @param {String} [name]
171
- @param {Object} [options]
172
- @return {Object} Returns token object
173
- */
174
- function getToken(name, options) {
175
- let renderer = (options && options.renderer) || chalk;
176
- return {
177
- name,
178
- token: `<${name}></${name}>`,
179
- pattern: getColorTokenRegex(name),
180
- render: this.renderStylesFactory(renderer, name),
181
- };
182
- }
183
-
184
- function setToken(result, color) {
185
- result[color.name] = color;
186
- return result;
187
- }
188
-
189
- function escapeToken(match, pattern) {
190
- let output = pattern.replace(/~/g, '');
191
- return `<${output}>`;
192
- }
193
-
194
- function unshiftValue(array, value) {
195
- array.unshift(value);
196
- return array;
197
- }
198
-
199
- /*
200
- Formatting colors for ember-cli help
201
-
202
- white: ember serve
203
- yellow: <arg-option, >
204
- cyan: --port, --important-option
205
- cyan: (Default: something), (Default: 4200)
206
- white: Description 1, Description 2
207
- cyan: (Required)
208
- */
@@ -1,44 +0,0 @@
1
- 'use strict';
2
-
3
- const spawn = require('child_process').spawn;
4
-
5
- function openEditor(file) {
6
- if (!openEditor.canEdit()) {
7
- throw new Error('EDITOR environment variable is not set');
8
- }
9
-
10
- if (!file) {
11
- throw new Error('No `file` option provided');
12
- }
13
-
14
- let editorArgs = openEditor._env().EDITOR.split(' ');
15
- let editor = editorArgs.shift();
16
- const args = [file].concat(editorArgs);
17
- let editProcess = openEditor._spawn(editor, args, { stdio: 'inherit' });
18
-
19
- return new Promise((resolve, reject) => {
20
- editProcess.on('close', (code) => {
21
- if (code === 0) {
22
- resolve();
23
- } else {
24
- reject(
25
- new Error(`Spawn('${editor}', [${args.join(',')}]) exited with a non zero error status code: '${code}'`)
26
- );
27
- }
28
- });
29
- });
30
- }
31
-
32
- openEditor.canEdit = function () {
33
- return openEditor._env().EDITOR !== undefined;
34
- };
35
-
36
- openEditor._env = function () {
37
- return process.env;
38
- };
39
-
40
- openEditor._spawn = function () {
41
- return spawn.apply(this, arguments);
42
- };
43
-
44
- module.exports = openEditor;
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- function supportEmoji() {
4
- const hasEmojiTurnedOff = process.argv.indexOf('--no-emoji') > -1;
5
- return process.stdout.isTTY && process.platform !== 'win32' && !hasEmojiTurnedOff;
6
- }
7
-
8
- const areEmojiSupported = supportEmoji();
9
-
10
- module.exports = function prependEmoji(emoji, msg) {
11
- return areEmojiSupported ? `${emoji} ${msg}` : msg;
12
- };
@@ -1,102 +0,0 @@
1
- 'use strict';
2
-
3
- const { default: chalk } = require('chalk');
4
- const EOL = require('os').EOL;
5
-
6
- module.exports = function (initialMargin, shouldDescriptionBeGrey) {
7
- initialMargin = initialMargin || '';
8
-
9
- let output = '';
10
-
11
- let options = this.anonymousOptions;
12
-
13
- // <anonymous-option-1> ...
14
- if (options.length) {
15
- output += ` ${chalk.yellow(
16
- options
17
- .map((option) => {
18
- // blueprints we insert brackets, commands already have them
19
- if (option.indexOf('<') === 0) {
20
- return option;
21
- } else {
22
- return `<${option}>`;
23
- }
24
- })
25
- .join(' ')
26
- )}`;
27
- }
28
-
29
- options = this.availableOptions;
30
-
31
- // <options...>
32
- if (options.length) {
33
- output += ` ${chalk.cyan('<options...>')}`;
34
- }
35
-
36
- // Description
37
- let description = this.description;
38
- if (description) {
39
- if (shouldDescriptionBeGrey) {
40
- description = chalk.grey(description);
41
- }
42
- output += `${EOL + initialMargin} ${description}`;
43
- }
44
-
45
- // aliases: a b c
46
- if (this.aliases && this.aliases.length) {
47
- output += `${EOL + initialMargin} ${chalk.grey(`aliases: ${this.aliases.filter((a) => a).join(', ')}`)}`;
48
- }
49
-
50
- // --available-option (Required) (Default: value)
51
- // ...
52
- options.forEach((option) => {
53
- output += `${EOL + initialMargin} ${chalk.cyan(`--${option.name}`)}`;
54
-
55
- if (option.values) {
56
- output += chalk.cyan(`=${option.values.join('|')}`);
57
- }
58
-
59
- if (option.type) {
60
- let types = Array.isArray(option.type) ? option.type.map(formatType).join(', ') : formatType(option.type);
61
-
62
- output += ` ${chalk.cyan(`(${types})`)}`;
63
- }
64
-
65
- if (option.required) {
66
- output += ` ${chalk.cyan('(Required)')}`;
67
- }
68
-
69
- if (option.default !== undefined) {
70
- output += ` ${chalk.cyan(`(Default: ${formatValue(option.default)})`)}`;
71
- }
72
-
73
- if (option.description) {
74
- output += ` ${option.description}`;
75
- }
76
-
77
- if (option.aliases && option.aliases.length) {
78
- output += `${EOL + initialMargin} ${chalk.grey(
79
- `aliases: ${option.aliases
80
- .map((a) => {
81
- if (typeof a === 'string') {
82
- return (a.length > 4 ? '--' : '-') + a + (option.type === Boolean ? '' : ' <value>');
83
- } else {
84
- let key = Object.keys(a)[0];
85
- return `${(key.length > 4 ? '--' : '-') + key} (--${option.name}=${formatValue(a[key])})`;
86
- }
87
- })
88
- .join(', ')}`
89
- )}`;
90
- }
91
- });
92
-
93
- return output;
94
- };
95
-
96
- function formatType(type) {
97
- return typeof type === 'string' ? formatValue(type) : type.name;
98
- }
99
-
100
- function formatValue(val) {
101
- return val === '' ? '""' : val;
102
- }
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function processTemplate(content, context) {
4
- let options = {
5
- evaluate: /<%([\s\S]+?)%>/g,
6
- interpolate: /<%=([\s\S]+?)%>/g,
7
- escape: /<%-([\s\S]+?)%>/g,
8
- };
9
- return require('lodash/template')(content, options)(context);
10
- };
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- /*
4
- *
5
- * given an array of functions, that may or may not return promises sequence
6
- * will invoke them sequentially. If a promise is encountered sequence will
7
- * wait until it fulfills before moving to the next entry.
8
- *
9
- * ```js
10
- * var tasks = [
11
- * function() { return Promise.resolve(1); },
12
- * 2,
13
- * function() { return timeout(1000).then(function() { return 3; } },
14
- * ];
15
- *
16
- * sequence(tasks).then(function(results) {
17
- * results === [
18
- * 1,
19
- * 2,
20
- * 3
21
- * ]
22
- * });
23
- * ```
24
- *
25
- * @method sequence
26
- * @param tasks
27
- * @return Promise<Array>
28
- *
29
- */
30
- module.exports = async function sequence(tasks) {
31
- let length = tasks.length;
32
- let results = [];
33
-
34
- for (let i = 0; i < length; ++i) {
35
- let task = tasks[i];
36
- let prevResult = results[i - 1];
37
-
38
- results.push(typeof task === 'function' ? await task(prevResult) : await task);
39
- }
40
-
41
- return results;
42
- };
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
-
5
- let regex = /^[./]$/;
6
-
7
- function walkUp(thePath) {
8
- let paths = [];
9
-
10
- let currentPath = thePath;
11
- // eslint-disable-next-line no-constant-condition
12
- while (true) {
13
- currentPath = path.dirname(currentPath);
14
- if (regex.test(currentPath)) {
15
- break;
16
- }
17
- paths.push(currentPath);
18
- }
19
-
20
- return paths;
21
- }
22
-
23
- module.exports = walkUp;