extension-create 2.0.0-rc.24 → 2.0.0-rc.26
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/dist/module.js +159 -111
- package/package.json +3 -3
package/dist/module.js
CHANGED
|
@@ -1,34 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
+
return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
+
}();
|
|
5
|
+
var __webpack_require__ = {};
|
|
6
|
+
(()=>{
|
|
7
|
+
__webpack_require__.n = (module)=>{
|
|
8
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
9
|
+
__webpack_require__.d(getter, {
|
|
10
|
+
a: getter
|
|
11
|
+
});
|
|
12
|
+
return getter;
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
17
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: definition[key]
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
25
|
+
})();
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.r = (exports1)=>{
|
|
28
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
29
|
+
value: 'Module'
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
32
|
+
value: true
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __webpack_exports__ = {};
|
|
37
|
+
__webpack_require__.r(__webpack_exports__);
|
|
38
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
39
|
+
extensionCreate: ()=>extensionCreate
|
|
40
|
+
});
|
|
41
|
+
const external_path_namespaceObject = require("path");
|
|
42
|
+
const external_fs_namespaceObject = require("fs");
|
|
43
|
+
const external_chalk_namespaceObject = require("chalk");
|
|
44
|
+
var external_chalk_default = /*#__PURE__*/ __webpack_require__.n(external_chalk_namespaceObject);
|
|
45
|
+
const external_package_manager_detector_namespaceObject = require("package-manager-detector");
|
|
9
46
|
function destinationNotWriteable(workingDir) {
|
|
10
|
-
const workingDirFolder =
|
|
11
|
-
return `${
|
|
47
|
+
const workingDirFolder = external_path_namespaceObject.basename(workingDir);
|
|
48
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Failed to write in the destination directory\n\nPath is not writable. Ensure you have write permissions for this folder.\n${external_chalk_default().red('NOT WRITEABLE')}: ${external_chalk_default().underline(workingDirFolder)}`;
|
|
12
49
|
}
|
|
13
50
|
async function directoryHasConflicts(projectPath, conflictingFiles) {
|
|
14
|
-
const projectName =
|
|
15
|
-
let message = `\nConflict! Path to ${
|
|
51
|
+
const projectName = external_path_namespaceObject.basename(projectPath);
|
|
52
|
+
let message = `\nConflict! Path to ${external_chalk_default().cyan(projectName)} includes conflicting files:\n\n`;
|
|
16
53
|
for (const file of conflictingFiles){
|
|
17
|
-
const stats = await
|
|
18
|
-
message += stats.isDirectory() ? `${
|
|
54
|
+
const stats = await external_fs_namespaceObject.promises.lstat(external_path_namespaceObject.join(projectPath, file));
|
|
55
|
+
message += stats.isDirectory() ? `${external_chalk_default().gray('-')} ${external_chalk_default().yellow(file)}\n` : `${external_chalk_default().gray('-')} ${external_chalk_default().yellow(file)}\n`;
|
|
19
56
|
}
|
|
20
|
-
message += `\nYou need to either rename/remove the files listed above, or choose a new directory name for your extension.\n\nPath to conflicting directory: ${
|
|
57
|
+
message += `\nYou need to either rename/remove the files listed above, or choose a new directory name for your extension.\n\nPath to conflicting directory: ${external_chalk_default().underline(projectPath)}`;
|
|
21
58
|
return message;
|
|
22
59
|
}
|
|
23
60
|
function noProjectName() {
|
|
24
|
-
return `${
|
|
61
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} You need to provide an extension name to create one. See ${external_chalk_default().yellow('--help')} for command info.`;
|
|
25
62
|
}
|
|
26
63
|
function noUrlAllowed() {
|
|
27
|
-
return `${
|
|
64
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} URLs are not allowed as a project path. Either write a name or a path to a local folder.`;
|
|
28
65
|
}
|
|
29
66
|
async function successfullInstall(projectPath, projectName) {
|
|
30
|
-
const relativePath =
|
|
31
|
-
const pm = await (0,
|
|
67
|
+
const relativePath = external_path_namespaceObject.relative(process.cwd(), projectPath);
|
|
68
|
+
const pm = await (0, external_package_manager_detector_namespaceObject.detect)();
|
|
32
69
|
let command = 'npm run';
|
|
33
70
|
switch(null == pm ? void 0 : pm.name){
|
|
34
71
|
case 'yarn':
|
|
@@ -43,10 +80,10 @@ async function successfullInstall(projectPath, projectName) {
|
|
|
43
80
|
if (process.env.npm_config_user_agent) {
|
|
44
81
|
if (process.env.npm_config_user_agent.includes('pnpm')) command = 'pnpm dev';
|
|
45
82
|
}
|
|
46
|
-
return `\u{1F9E9} - ${
|
|
83
|
+
return `\u{1F9E9} - ${external_chalk_default().green('Success!')} Extension ${external_chalk_default().cyan(projectName)} created.\n\nNow ${external_chalk_default().magenta(`cd ${external_chalk_default().underline(relativePath)}`)} and ${external_chalk_default().magenta(`${command}`)} to open a new browser instance\nwith your extension installed, loaded, and enabled for development.\n\n${external_chalk_default().green('You are ready')}. Time to hack on your extension!`;
|
|
47
84
|
}
|
|
48
85
|
function startingNewExtension(projectName) {
|
|
49
|
-
return `\u{1F423} - Starting a new browser extension named ${
|
|
86
|
+
return `\u{1F423} - Starting a new browser extension named ${external_chalk_default().cyan(projectName)}...`;
|
|
50
87
|
}
|
|
51
88
|
function checkingIfPathIsWriteable() {
|
|
52
89
|
return `\u{1F91E} - Checking if destination path is writeable...`;
|
|
@@ -55,117 +92,119 @@ function scanningPossiblyConflictingFiles() {
|
|
|
55
92
|
return "\uD83D\uDD0E - Scanning for potential conflicting files...";
|
|
56
93
|
}
|
|
57
94
|
function createDirectoryError(projectName, error) {
|
|
58
|
-
return `${
|
|
95
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't create directory ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error)}`;
|
|
59
96
|
}
|
|
60
97
|
function writingTypeDefinitions(projectName) {
|
|
61
|
-
return `\u{1F537} - Writing type definitions for ${
|
|
98
|
+
return `\u{1F537} - Writing type definitions for ${external_chalk_default().cyan(projectName)}...`;
|
|
62
99
|
}
|
|
63
100
|
function writingTypeDefinitionsError(error) {
|
|
64
|
-
return `${
|
|
101
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Failed to write the extension type definition.\n${external_chalk_default().red(error)}`;
|
|
65
102
|
}
|
|
66
103
|
function installingFromTemplate(projectName, templateName) {
|
|
67
|
-
if ('init' === templateName) return `\u{1F9F0} - Installing ${
|
|
68
|
-
return `\u{1F9F0} - Installing ${
|
|
104
|
+
if ('init' === templateName) return `\u{1F9F0} - Installing ${external_chalk_default().cyan(projectName)}...`;
|
|
105
|
+
return `\u{1F9F0} - Installing ${external_chalk_default().cyan(projectName)} from template ${external_chalk_default().magenta(templateName)}...`;
|
|
69
106
|
}
|
|
70
107
|
function installingFromTemplateError(projectName, template, error) {
|
|
71
|
-
return `${
|
|
108
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't find template ${external_chalk_default().magenta(template)} for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error)}`;
|
|
72
109
|
}
|
|
73
110
|
function initializingGitForRepository(projectName) {
|
|
74
|
-
return `\u{1F332} - Initializing git repository for ${
|
|
111
|
+
return `\u{1F332} - Initializing git repository for ${external_chalk_default().cyan(projectName)}...`;
|
|
75
112
|
}
|
|
76
113
|
function initializingGitForRepositoryFailed(gitCommand, gitArgs, code) {
|
|
77
|
-
return `${
|
|
114
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Command ${external_chalk_default().yellow(gitCommand)} ${external_chalk_default().yellow(gitArgs.join(' '))} failed with exit code ${code}`;
|
|
78
115
|
}
|
|
79
116
|
function initializingGitForRepositoryProcessError(projectName, error) {
|
|
80
|
-
return `${
|
|
117
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Child process error: Can't initialize ${external_chalk_default().yellow('git')} for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error.message)}`;
|
|
81
118
|
}
|
|
82
119
|
function initializingGitForRepositoryError(projectName, error) {
|
|
83
|
-
return `${
|
|
120
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't initialize ${external_chalk_default().yellow('git')} for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error.message || error.toString())}`;
|
|
84
121
|
}
|
|
85
122
|
function installingDependencies() {
|
|
86
123
|
return "\uD83D\uDEE0 - Installing dependencies... (takes a moment)";
|
|
87
124
|
}
|
|
88
125
|
function installingDependenciesFailed(gitCommand, gitArgs, code) {
|
|
89
|
-
return `${
|
|
126
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Command ${gitCommand} ${gitArgs.join(' ')} failed with exit code ${code}`;
|
|
90
127
|
}
|
|
91
128
|
function installingDependenciesProcessError(projectName, error) {
|
|
92
|
-
return `${
|
|
129
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Child process error: Can't install dependencies for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error)}`;
|
|
93
130
|
}
|
|
94
131
|
function cantInstallDependencies(projectName, error) {
|
|
95
|
-
return `${
|
|
132
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't install dependencies for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error.message || error.toString())}`;
|
|
96
133
|
}
|
|
97
134
|
function writingPackageJsonMetadata() {
|
|
98
|
-
return `\u{1F4DD} - Writing ${
|
|
135
|
+
return `\u{1F4DD} - Writing ${external_chalk_default().yellow('package.json')} metadata...`;
|
|
99
136
|
}
|
|
100
137
|
function writingPackageJsonMetadataError(projectName, error) {
|
|
101
|
-
return `${
|
|
138
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write ${external_chalk_default().yellow('package.json')} for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error)}`;
|
|
102
139
|
}
|
|
103
140
|
function writingManifestJsonMetadata() {
|
|
104
|
-
return `\u{1F4DC} - Writing ${
|
|
141
|
+
return `\u{1F4DC} - Writing ${external_chalk_default().yellow('manifest.json')} metadata...`;
|
|
105
142
|
}
|
|
106
143
|
function writingManifestJsonMetadataError(projectName, error) {
|
|
107
|
-
return `${
|
|
144
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write ${external_chalk_default().yellow('manifest.json')} for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error)}`;
|
|
108
145
|
}
|
|
109
146
|
function writingReadmeMetaData() {
|
|
110
|
-
return `\u{1F4C4} - Writing ${
|
|
147
|
+
return `\u{1F4C4} - Writing ${external_chalk_default().yellow('README.md')} metadata...`;
|
|
111
148
|
}
|
|
112
149
|
function writingGitIgnore() {
|
|
113
|
-
return `\u{1F648} - Writing ${
|
|
150
|
+
return `\u{1F648} - Writing ${external_chalk_default().yellow('.gitignore')} lines...`;
|
|
114
151
|
}
|
|
115
152
|
function writingReadmeMetaDataEError(projectName, error) {
|
|
116
|
-
return `${
|
|
153
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't write the ${external_chalk_default().yellow('README.md')} file for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error)}`;
|
|
117
154
|
}
|
|
118
155
|
function folderExists(projectName) {
|
|
119
|
-
return `\u{1F91D} - Ensuring ${
|
|
156
|
+
return `\u{1F91D} - Ensuring ${external_chalk_default().cyan(projectName)} folder exists...`;
|
|
120
157
|
}
|
|
121
158
|
function writingDirectoryError(error) {
|
|
122
|
-
return `${
|
|
159
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Error while checking directory writability:\n` + external_chalk_default().red(error);
|
|
123
160
|
}
|
|
124
161
|
function cantSetupBuiltInTests(projectName, error) {
|
|
125
|
-
return `${
|
|
162
|
+
return `${external_chalk_default().red("\u2716\uFE0E\u2716\uFE0E\u2716\uFE0E")} Can't setup built-in tests for ${external_chalk_default().cyan(projectName)}:\n${external_chalk_default().red(error)}`;
|
|
126
163
|
}
|
|
127
|
-
const
|
|
128
|
-
const
|
|
164
|
+
const promises_namespaceObject = require("fs/promises");
|
|
165
|
+
const external_url_namespaceObject = require("url");
|
|
166
|
+
const utils_filename = (0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__);
|
|
167
|
+
const utils_dirname = external_path_namespaceObject.dirname(utils_filename);
|
|
129
168
|
async function copyDirectoryWithSymlinks(source, destination) {
|
|
130
|
-
const entries = await
|
|
169
|
+
const entries = await promises_namespaceObject.readdir(source, {
|
|
131
170
|
withFileTypes: true
|
|
132
171
|
});
|
|
133
|
-
await
|
|
172
|
+
await promises_namespaceObject.mkdir(destination, {
|
|
134
173
|
recursive: true
|
|
135
174
|
});
|
|
136
175
|
for (const entry of entries){
|
|
137
|
-
const sourcePath =
|
|
138
|
-
const destPath =
|
|
176
|
+
const sourcePath = external_path_namespaceObject.join(source, entry.name);
|
|
177
|
+
const destPath = external_path_namespaceObject.join(destination, entry.name);
|
|
139
178
|
if (entry.isDirectory()) await copyDirectoryWithSymlinks(sourcePath, destPath);
|
|
140
179
|
else if (entry.isSymbolicLink()) {
|
|
141
|
-
const target = await
|
|
142
|
-
await
|
|
143
|
-
} else await
|
|
180
|
+
const target = await promises_namespaceObject.readlink(sourcePath);
|
|
181
|
+
await promises_namespaceObject.symlink(target, destPath);
|
|
182
|
+
} else await promises_namespaceObject.copyFile(sourcePath, destPath);
|
|
144
183
|
}
|
|
145
184
|
}
|
|
146
185
|
async function moveDirectoryContents(source, destination) {
|
|
147
|
-
await
|
|
186
|
+
await promises_namespaceObject.mkdir(destination, {
|
|
148
187
|
recursive: true
|
|
149
188
|
});
|
|
150
|
-
const entries = await
|
|
189
|
+
const entries = await promises_namespaceObject.readdir(source, {
|
|
151
190
|
withFileTypes: true
|
|
152
191
|
});
|
|
153
192
|
for (const entry of entries){
|
|
154
|
-
const sourcePath =
|
|
155
|
-
const destPath =
|
|
193
|
+
const sourcePath = external_path_namespaceObject.join(source, entry.name);
|
|
194
|
+
const destPath = external_path_namespaceObject.join(destination, entry.name);
|
|
156
195
|
if (entry.isDirectory()) await moveDirectoryContents(sourcePath, destPath);
|
|
157
196
|
else if (entry.isSymbolicLink()) {
|
|
158
|
-
const target = await
|
|
159
|
-
await
|
|
160
|
-
} else await
|
|
197
|
+
const target = await promises_namespaceObject.readlink(sourcePath);
|
|
198
|
+
await promises_namespaceObject.symlink(target, destPath);
|
|
199
|
+
} else await promises_namespaceObject.rename(sourcePath, destPath);
|
|
161
200
|
}
|
|
162
|
-
await
|
|
201
|
+
await promises_namespaceObject.rm(source, {
|
|
163
202
|
recursive: true,
|
|
164
203
|
force: true
|
|
165
204
|
});
|
|
166
205
|
}
|
|
167
206
|
async function getInstallCommand() {
|
|
168
|
-
const pm = await (0,
|
|
207
|
+
const pm = await (0, external_package_manager_detector_namespaceObject.detect)();
|
|
169
208
|
let command = 'npm';
|
|
170
209
|
if (process.env.npm_config_user_agent) {
|
|
171
210
|
if (process.env.npm_config_user_agent.includes('pnpm')) return 'pnpm';
|
|
@@ -183,13 +222,13 @@ async function getInstallCommand() {
|
|
|
183
222
|
return command;
|
|
184
223
|
}
|
|
185
224
|
function getTemplatePath(workingDir) {
|
|
186
|
-
const templatesDir =
|
|
187
|
-
return
|
|
225
|
+
const templatesDir = external_path_namespaceObject.resolve(utils_dirname, '..', 'template');
|
|
226
|
+
return external_path_namespaceObject.resolve(workingDir, templatesDir);
|
|
188
227
|
}
|
|
189
228
|
async function isDirectoryWriteable(directory, projectName) {
|
|
190
229
|
try {
|
|
191
230
|
console.log(folderExists(projectName));
|
|
192
|
-
await
|
|
231
|
+
await promises_namespaceObject.mkdir(directory, {
|
|
193
232
|
recursive: true
|
|
194
233
|
});
|
|
195
234
|
return true;
|
|
@@ -217,10 +256,10 @@ async function createDirectory(projectPath, projectName) {
|
|
|
217
256
|
console.error(destinationNotWriteable(projectPath));
|
|
218
257
|
process.exit(1);
|
|
219
258
|
}
|
|
220
|
-
const currentDir = await
|
|
259
|
+
const currentDir = await promises_namespaceObject.readdir(projectPath);
|
|
221
260
|
console.log(scanningPossiblyConflictingFiles());
|
|
222
261
|
const conflictingFiles = await Promise.all(currentDir.filter((file)=>!file.startsWith('.')).filter((file)=>!file.endsWith('.log')).filter((file)=>!allowlist.includes(file)).map(async (file)=>{
|
|
223
|
-
const stats = await
|
|
262
|
+
const stats = await promises_namespaceObject.lstat(external_path_namespaceObject.join(projectPath, file));
|
|
224
263
|
return stats.isDirectory() ? `${file}/` : `${file}`;
|
|
225
264
|
}));
|
|
226
265
|
if (conflictingFiles.length > 0) {
|
|
@@ -232,10 +271,10 @@ async function createDirectory(projectPath, projectName) {
|
|
|
232
271
|
process.exit(1);
|
|
233
272
|
}
|
|
234
273
|
}
|
|
235
|
-
const import_local_template_filename = (0,
|
|
236
|
-
const import_local_template_dirname =
|
|
274
|
+
const import_local_template_filename = (0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__);
|
|
275
|
+
const import_local_template_dirname = external_path_namespaceObject.dirname(import_local_template_filename);
|
|
237
276
|
async function importLocalTemplate(projectPath, projectName, template) {
|
|
238
|
-
const localTemplatePath =
|
|
277
|
+
const localTemplatePath = external_path_namespaceObject.resolve(import_local_template_dirname, 'template');
|
|
239
278
|
try {
|
|
240
279
|
console.log(installingFromTemplate(projectName, template));
|
|
241
280
|
await copyDirectoryWithSymlinks(localTemplatePath, projectPath);
|
|
@@ -244,30 +283,32 @@ async function importLocalTemplate(projectPath, projectName, template) {
|
|
|
244
283
|
process.exit(1);
|
|
245
284
|
}
|
|
246
285
|
}
|
|
247
|
-
const
|
|
248
|
-
|
|
286
|
+
const external_go_git_it_namespaceObject = require("go-git-it");
|
|
287
|
+
var external_go_git_it_default = /*#__PURE__*/ __webpack_require__.n(external_go_git_it_namespaceObject);
|
|
288
|
+
const import_external_template_filename = (0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__);
|
|
289
|
+
const import_external_template_dirname = external_path_namespaceObject.dirname(import_external_template_filename);
|
|
249
290
|
async function importExternalTemplate(projectPath, projectName, template) {
|
|
250
|
-
const installationPath =
|
|
251
|
-
const templateName =
|
|
291
|
+
const installationPath = external_path_namespaceObject.dirname(projectPath);
|
|
292
|
+
const templateName = external_path_namespaceObject.basename(template);
|
|
252
293
|
const examplesUrl = 'https://github.com/extension-js/extension.js/tree/main/examples';
|
|
253
294
|
const templateUrl = `${examplesUrl}/${template}`;
|
|
254
295
|
try {
|
|
255
|
-
await
|
|
296
|
+
await promises_namespaceObject.mkdir(projectPath, {
|
|
256
297
|
recursive: true
|
|
257
298
|
});
|
|
258
299
|
if ('development' === process.env.EXTENSION_ENV) {
|
|
259
300
|
console.log(installingFromTemplate(projectName, template));
|
|
260
|
-
const localTemplatePath =
|
|
301
|
+
const localTemplatePath = external_path_namespaceObject.join(import_external_template_dirname, '..', '..', '..', 'examples', templateName);
|
|
261
302
|
await copyDirectoryWithSymlinks(localTemplatePath, projectPath);
|
|
262
303
|
} else {
|
|
263
|
-
const tempPath =
|
|
264
|
-
await
|
|
304
|
+
const tempPath = external_path_namespaceObject.join(installationPath, projectName + '-temp');
|
|
305
|
+
await promises_namespaceObject.mkdir(tempPath, {
|
|
265
306
|
recursive: true
|
|
266
307
|
});
|
|
267
|
-
await (
|
|
268
|
-
const srcPath =
|
|
308
|
+
await external_go_git_it_default()(templateUrl, tempPath, installingFromTemplate(projectName, templateName));
|
|
309
|
+
const srcPath = external_path_namespaceObject.join(tempPath, templateName);
|
|
269
310
|
await moveDirectoryContents(srcPath, projectPath);
|
|
270
|
-
await
|
|
311
|
+
await promises_namespaceObject.rm(tempPath, {
|
|
271
312
|
recursive: true,
|
|
272
313
|
force: true
|
|
273
314
|
});
|
|
@@ -284,8 +325,8 @@ const extensionJsPackageJsonScripts = {
|
|
|
284
325
|
};
|
|
285
326
|
async function overridePackageJson(projectPath, projectName, { template, cliVersion }) {
|
|
286
327
|
const templatePath = getTemplatePath(process.cwd());
|
|
287
|
-
const packageJsonPath = isExternalTemplate(template) ?
|
|
288
|
-
const packageJsonContent = await
|
|
328
|
+
const packageJsonPath = isExternalTemplate(template) ? external_path_namespaceObject.join(projectPath, 'package.json') : external_path_namespaceObject.join(templatePath, 'package.json');
|
|
329
|
+
const packageJsonContent = await promises_namespaceObject.readFile(packageJsonPath);
|
|
289
330
|
const packageJson = JSON.parse(packageJsonContent.toString());
|
|
290
331
|
packageJson.scripts = packageJson.scripts || {};
|
|
291
332
|
packageJson.dependencies = packageJson.dependencies || {};
|
|
@@ -295,7 +336,7 @@ async function overridePackageJson(projectPath, projectName, { template, cliVers
|
|
|
295
336
|
};
|
|
296
337
|
const packageMetadata = {
|
|
297
338
|
...packageJson,
|
|
298
|
-
name:
|
|
339
|
+
name: external_path_namespaceObject.basename(projectPath),
|
|
299
340
|
private: true,
|
|
300
341
|
scripts: {
|
|
301
342
|
...packageJson.scripts,
|
|
@@ -311,12 +352,13 @@ async function overridePackageJson(projectPath, projectName, { template, cliVers
|
|
|
311
352
|
};
|
|
312
353
|
try {
|
|
313
354
|
console.log(writingPackageJsonMetadata());
|
|
314
|
-
await
|
|
355
|
+
await promises_namespaceObject.writeFile(external_path_namespaceObject.join(projectPath, 'package.json'), JSON.stringify(packageMetadata, null, 2));
|
|
315
356
|
} catch (error) {
|
|
316
357
|
console.error(writingPackageJsonMetadataError(projectName, error));
|
|
317
358
|
process.exit(1);
|
|
318
359
|
}
|
|
319
360
|
}
|
|
361
|
+
const external_cross_spawn_namespaceObject = require("cross-spawn");
|
|
320
362
|
function getInstallArgs() {
|
|
321
363
|
return [
|
|
322
364
|
'install',
|
|
@@ -324,16 +366,16 @@ function getInstallArgs() {
|
|
|
324
366
|
];
|
|
325
367
|
}
|
|
326
368
|
async function installDependencies(projectPath, projectName) {
|
|
327
|
-
const nodeModulesPath =
|
|
369
|
+
const nodeModulesPath = external_path_namespaceObject.join(projectPath, 'node_modules');
|
|
328
370
|
const command = await getInstallCommand();
|
|
329
371
|
const dependenciesArgs = getInstallArgs();
|
|
330
372
|
console.log(installingDependencies());
|
|
331
373
|
try {
|
|
332
|
-
await
|
|
374
|
+
await external_fs_namespaceObject.promises.mkdir(nodeModulesPath, {
|
|
333
375
|
recursive: true
|
|
334
376
|
});
|
|
335
377
|
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
|
|
336
|
-
const child = (0,
|
|
378
|
+
const child = (0, external_cross_spawn_namespaceObject.spawn)(command, dependenciesArgs, {
|
|
337
379
|
stdio,
|
|
338
380
|
cwd: projectPath
|
|
339
381
|
});
|
|
@@ -352,45 +394,45 @@ async function installDependencies(projectPath, projectName) {
|
|
|
352
394
|
process.exit(1);
|
|
353
395
|
}
|
|
354
396
|
}
|
|
355
|
-
const write_readme_file_filename = (0,
|
|
356
|
-
const write_readme_file_dirname =
|
|
397
|
+
const write_readme_file_filename = (0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__);
|
|
398
|
+
const write_readme_file_dirname = external_path_namespaceObject.dirname(write_readme_file_filename);
|
|
357
399
|
async function writeReadmeFile(projectPath, projectName) {
|
|
358
|
-
const initTemplateReadme = await
|
|
400
|
+
const initTemplateReadme = await promises_namespaceObject.readFile(external_path_namespaceObject.join(write_readme_file_dirname, 'template', 'README.md'), 'utf-8');
|
|
359
401
|
const installCommand = await getInstallCommand();
|
|
360
|
-
const manifestJsonPath =
|
|
361
|
-
const manifestJson = JSON.parse(await
|
|
402
|
+
const manifestJsonPath = external_path_namespaceObject.join(projectPath, 'manifest.json');
|
|
403
|
+
const manifestJson = JSON.parse(await promises_namespaceObject.readFile(manifestJsonPath, 'utf-8'));
|
|
362
404
|
const readmeFileEdited = initTemplateReadme.replaceAll('[projectName]', projectName).replaceAll("[templateDescription]", manifestJson.description).replaceAll('[runCommand]', installCommand);
|
|
363
405
|
try {
|
|
364
406
|
console.log(writingReadmeMetaData());
|
|
365
|
-
await
|
|
407
|
+
await promises_namespaceObject.mkdir(projectPath, {
|
|
366
408
|
recursive: true
|
|
367
409
|
});
|
|
368
|
-
await
|
|
410
|
+
await promises_namespaceObject.writeFile(external_path_namespaceObject.join(projectPath, 'README.md'), readmeFileEdited);
|
|
369
411
|
} catch (error) {
|
|
370
412
|
console.error(writingReadmeMetaDataEError(projectName, error));
|
|
371
413
|
process.exit(1);
|
|
372
414
|
}
|
|
373
415
|
}
|
|
374
416
|
async function writeManifestJson(projectPath, projectName) {
|
|
375
|
-
const manifestJsonPath =
|
|
376
|
-
const manifestJsonContent = await
|
|
417
|
+
const manifestJsonPath = external_path_namespaceObject.join(projectPath, 'manifest.json');
|
|
418
|
+
const manifestJsonContent = await promises_namespaceObject.readFile(manifestJsonPath);
|
|
377
419
|
const manifestJson = JSON.parse(manifestJsonContent.toString());
|
|
378
420
|
const manifestMetadata = {
|
|
379
421
|
...manifestJson,
|
|
380
|
-
name:
|
|
422
|
+
name: external_path_namespaceObject.basename(projectPath),
|
|
381
423
|
author: 'Your Name'
|
|
382
424
|
};
|
|
383
425
|
try {
|
|
384
426
|
console.log(writingManifestJsonMetadata());
|
|
385
|
-
await
|
|
427
|
+
await promises_namespaceObject.writeFile(external_path_namespaceObject.join(projectPath, 'manifest.json'), JSON.stringify(manifestMetadata, null, 2));
|
|
386
428
|
} catch (error) {
|
|
387
429
|
console.error(writingManifestJsonMetadataError(projectName, error));
|
|
388
430
|
process.exit(1);
|
|
389
431
|
}
|
|
390
432
|
}
|
|
391
433
|
async function generateExtensionTypes(projectPath, projectName) {
|
|
392
|
-
const extensionEnvFile =
|
|
393
|
-
const typePath = 'development' === process.env.EXTENSION_ENV ?
|
|
434
|
+
const extensionEnvFile = external_path_namespaceObject.join(projectPath, 'extension-env.d.ts');
|
|
435
|
+
const typePath = 'development' === process.env.EXTENSION_ENV ? external_path_namespaceObject.resolve(process.cwd(), 'programs/cli/types') : 'extension/dist/types';
|
|
394
436
|
const fileContent = `\
|
|
395
437
|
// Required Extension.js types for TypeScript projects.
|
|
396
438
|
// This file is auto-generated and should not be excluded.
|
|
@@ -403,11 +445,11 @@ async function generateExtensionTypes(projectPath, projectName) {
|
|
|
403
445
|
/// <reference types="${typePath}/polyfill.d.ts" />
|
|
404
446
|
`;
|
|
405
447
|
try {
|
|
406
|
-
await
|
|
448
|
+
await promises_namespaceObject.mkdir(projectPath, {
|
|
407
449
|
recursive: true
|
|
408
450
|
});
|
|
409
451
|
console.log(writingTypeDefinitions(projectName));
|
|
410
|
-
await
|
|
452
|
+
await promises_namespaceObject.writeFile(extensionEnvFile, fileContent);
|
|
411
453
|
} catch (error) {
|
|
412
454
|
console.error(writingTypeDefinitionsError(error));
|
|
413
455
|
process.exit(1);
|
|
@@ -464,8 +506,8 @@ const globalLines = [
|
|
|
464
506
|
...extensionJsFiles
|
|
465
507
|
];
|
|
466
508
|
async function writeGitignore(projectPath) {
|
|
467
|
-
const gitIgnorePath =
|
|
468
|
-
const fileHandle = await
|
|
509
|
+
const gitIgnorePath = external_path_namespaceObject.join(projectPath, '.gitignore');
|
|
510
|
+
const fileHandle = await promises_namespaceObject.open(gitIgnorePath, 'a+').catch((err)=>{
|
|
469
511
|
console.error(err);
|
|
470
512
|
process.exit(1);
|
|
471
513
|
});
|
|
@@ -493,7 +535,7 @@ async function initializeGitRepository(projectPath, projectName) {
|
|
|
493
535
|
console.log(initializingGitForRepository(projectName));
|
|
494
536
|
try {
|
|
495
537
|
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
|
|
496
|
-
const child = (0,
|
|
538
|
+
const child = (0, external_cross_spawn_namespaceObject.spawn)(gitCommand, gitArgs, {
|
|
497
539
|
stdio,
|
|
498
540
|
cwd: projectPath
|
|
499
541
|
});
|
|
@@ -514,8 +556,8 @@ async function initializeGitRepository(projectPath, projectName) {
|
|
|
514
556
|
}
|
|
515
557
|
async function setupBuiltInTests(projectPath, projectName) {
|
|
516
558
|
try {
|
|
517
|
-
const testSpecPath =
|
|
518
|
-
if (
|
|
559
|
+
const testSpecPath = external_path_namespaceObject.join(projectPath, 'tests', 'templates.spec.ts');
|
|
560
|
+
if (external_fs_namespaceObject.existsSync(testSpecPath)) external_fs_namespaceObject.unlinkSync(testSpecPath);
|
|
519
561
|
} catch (error) {
|
|
520
562
|
console.error(cantSetupBuiltInTests(projectName, error));
|
|
521
563
|
process.exit(1);
|
|
@@ -524,8 +566,8 @@ async function setupBuiltInTests(projectPath, projectName) {
|
|
|
524
566
|
async function extensionCreate(projectNameInput, { cliVersion, template = 'init', install = true }) {
|
|
525
567
|
if (!projectNameInput) throw new Error(noProjectName());
|
|
526
568
|
if (projectNameInput.startsWith('http')) throw new Error(noUrlAllowed());
|
|
527
|
-
const projectPath =
|
|
528
|
-
const projectName =
|
|
569
|
+
const projectPath = external_path_namespaceObject.isAbsolute(projectNameInput) ? projectNameInput : external_path_namespaceObject.join(process.cwd(), projectNameInput);
|
|
570
|
+
const projectName = external_path_namespaceObject.basename(projectPath);
|
|
529
571
|
try {
|
|
530
572
|
await createDirectory(projectPath, projectName);
|
|
531
573
|
if ('init' === template) await importLocalTemplate(projectPath, projectName, template);
|
|
@@ -548,4 +590,10 @@ async function extensionCreate(projectNameInput, { cliVersion, template = 'init'
|
|
|
548
590
|
throw error;
|
|
549
591
|
}
|
|
550
592
|
}
|
|
551
|
-
|
|
593
|
+
exports.extensionCreate = __webpack_exports__.extensionCreate;
|
|
594
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
595
|
+
"extensionCreate"
|
|
596
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
597
|
+
Object.defineProperty(exports, '__esModule', {
|
|
598
|
+
value: true
|
|
599
|
+
});
|
package/package.json
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=18"
|
|
10
10
|
},
|
|
11
|
-
"type": "module",
|
|
12
11
|
"exports": {
|
|
13
12
|
".": {
|
|
14
13
|
"types": "./dist/module.d.ts",
|
|
15
|
-
"import": "./dist/module.js"
|
|
14
|
+
"import": "./dist/module.js",
|
|
15
|
+
"require": "./dist/module.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"main": "./dist/module.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"name": "extension-create",
|
|
24
|
-
"version": "2.0.0-rc.
|
|
24
|
+
"version": "2.0.0-rc.26",
|
|
25
25
|
"description": "The create step of Extension.js",
|
|
26
26
|
"author": {
|
|
27
27
|
"name": "Cezar Augusto",
|