extension-create 3.1.0-next.8 → 3.2.0-next.2
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/lib/package-manager.d.ts +3 -0
- package/dist/lib/utils.d.ts +1 -4
- package/dist/module.js +46 -53
- package/dist/steps/preflight-optional-deps.d.ts +1 -0
- package/dist/steps/write-package-json.d.ts +1 -1
- package/package.json +1 -2
- package/dist/lib/types.d.ts +0 -26
- package/dist/steps/import-local-template.d.ts +0 -1
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export declare function copyDirectory(source: string, destination: string): Promise<void[]>;
|
|
2
1
|
export declare function copyDirectoryWithSymlinks(source: string, destination: string): Promise<void>;
|
|
3
2
|
export declare function moveDirectoryContents(source: string, destination: string): Promise<void>;
|
|
4
|
-
export declare function getInstallCommand(): Promise<
|
|
5
|
-
export declare function getTemplatePath(workingDir: string): string;
|
|
3
|
+
export declare function getInstallCommand(): Promise<"pnpm" | "yarn" | "npm">;
|
|
6
4
|
export declare function isDirectoryWriteable(directory: string, projectName: string): Promise<boolean>;
|
|
7
|
-
export declare function isExternalTemplate(_templateName: string): boolean;
|
|
8
5
|
export declare function isTypeScriptTemplate(templateName: string): boolean;
|
package/dist/module.js
CHANGED
|
@@ -42,7 +42,18 @@ const external_path_namespaceObject = require("path");
|
|
|
42
42
|
const external_fs_namespaceObject = require("fs");
|
|
43
43
|
const external_pintor_namespaceObject = require("pintor");
|
|
44
44
|
var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_namespaceObject);
|
|
45
|
-
|
|
45
|
+
function detectPackageManagerFromEnv() {
|
|
46
|
+
const userAgent = process.env.npm_config_user_agent || '';
|
|
47
|
+
if (userAgent.includes('pnpm')) return 'pnpm';
|
|
48
|
+
if (userAgent.includes('yarn')) return 'yarn';
|
|
49
|
+
if (userAgent.includes('npm')) return 'npm';
|
|
50
|
+
const execPath = process.env.npm_execpath || process.env.NPM_EXEC_PATH || '';
|
|
51
|
+
if (execPath.includes('pnpm')) return 'pnpm';
|
|
52
|
+
if (execPath.includes('yarn')) return 'yarn';
|
|
53
|
+
execPath.includes('npm');
|
|
54
|
+
return 'npm';
|
|
55
|
+
}
|
|
56
|
+
const statusPrefix = external_pintor_default().brightBlue('►►►');
|
|
46
57
|
function destinationNotWriteable(workingDir) {
|
|
47
58
|
const workingDirFolder = external_path_namespaceObject.basename(workingDir);
|
|
48
59
|
return `${external_pintor_default().red('Error')} Couldn't write to the destination directory.\n${external_pintor_default().red('Next step: choose a writable path or update folder permissions.')}\n${external_pintor_default().red('Path')} ${external_pintor_default().underline(workingDirFolder)}`;
|
|
@@ -65,10 +76,10 @@ function noUrlAllowed() {
|
|
|
65
76
|
}
|
|
66
77
|
async function successfullInstall(projectPath, projectName, depsInstalled) {
|
|
67
78
|
const relativePath = external_path_namespaceObject.relative(process.cwd(), projectPath);
|
|
68
|
-
const pm =
|
|
79
|
+
const pm = detectPackageManagerFromEnv();
|
|
69
80
|
let command = 'npm run';
|
|
70
81
|
let installCmd = 'npm install';
|
|
71
|
-
switch(pm
|
|
82
|
+
switch(pm){
|
|
72
83
|
case 'yarn':
|
|
73
84
|
command = 'yarn dev';
|
|
74
85
|
installCmd = 'yarn';
|
|
@@ -81,42 +92,37 @@ async function successfullInstall(projectPath, projectName, depsInstalled) {
|
|
|
81
92
|
command = 'npm run dev';
|
|
82
93
|
installCmd = 'npm install';
|
|
83
94
|
}
|
|
84
|
-
if (process.env.npm_config_user_agent) {
|
|
85
|
-
if (process.env.npm_config_user_agent.includes('pnpm')) {
|
|
86
|
-
command = 'pnpm dev';
|
|
87
|
-
installCmd = 'pnpm install';
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
95
|
const steps = depsInstalled ? ` 1. ${external_pintor_default().blue('cd')} ${external_pintor_default().underline(relativePath)}\n 2. ${external_pintor_default().blue(command)} (runs a fresh browser profile with your extension loaded)\n` : ` 1. ${external_pintor_default().blue('cd')} ${external_pintor_default().underline(relativePath)}\n 2. ${external_pintor_default().blue(installCmd)}\n 3. ${external_pintor_default().blue(command)} (runs a fresh browser profile with your extension loaded)\n`;
|
|
91
|
-
|
|
96
|
+
const depsNote = depsInstalled ? `\n${external_pintor_default().gray('Dependencies installed. You can start developing now.')}\n` : '\n';
|
|
97
|
+
return `${statusPrefix} ${external_pintor_default().green('Created')} ${external_pintor_default().blue(projectName)}\n\nNext steps:\n\n` + steps + depsNote;
|
|
92
98
|
}
|
|
93
99
|
function startingNewExtension(projectName) {
|
|
94
|
-
return
|
|
100
|
+
return `${statusPrefix} Creating ${external_pintor_default().blue(projectName)}...`;
|
|
95
101
|
}
|
|
96
102
|
function checkingIfPathIsWriteable() {
|
|
97
|
-
return
|
|
103
|
+
return `${statusPrefix} Checking if the destination path is writable...`;
|
|
98
104
|
}
|
|
99
105
|
function scanningPossiblyConflictingFiles() {
|
|
100
|
-
return
|
|
106
|
+
return `${statusPrefix} Scanning for conflicting files...`;
|
|
101
107
|
}
|
|
102
108
|
function createDirectoryError(projectName, error) {
|
|
103
109
|
return `${external_pintor_default().red('Error')} Couldn't create directory ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: check the path and permissions, then try again.')}`;
|
|
104
110
|
}
|
|
105
111
|
function writingTypeDefinitions(projectName) {
|
|
106
|
-
return
|
|
112
|
+
return `${statusPrefix} Writing type definitions for ${external_pintor_default().blue(projectName)}...`;
|
|
107
113
|
}
|
|
108
114
|
function writingTypeDefinitionsError(error) {
|
|
109
115
|
return `${external_pintor_default().red('Error')} Couldn't write the extension type definitions.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: check file permissions, then try again.')}`;
|
|
110
116
|
}
|
|
111
117
|
function installingFromTemplate(projectName, templateName) {
|
|
112
|
-
if ('init' === templateName) return
|
|
113
|
-
return
|
|
118
|
+
if ('init' === templateName) return `${statusPrefix} Installing ${external_pintor_default().blue(projectName)}...`;
|
|
119
|
+
return `${statusPrefix} Installing ${external_pintor_default().blue(projectName)} from template ${external_pintor_default().yellow(templateName)}...`;
|
|
114
120
|
}
|
|
115
121
|
function installingFromTemplateError(projectName, template, error) {
|
|
116
122
|
return `${external_pintor_default().red('Error')} Couldn't find template ${external_pintor_default().yellow(template)} for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: choose a valid template name or URL.')}`;
|
|
117
123
|
}
|
|
118
124
|
function initializingGitForRepository(projectName) {
|
|
119
|
-
return
|
|
125
|
+
return `${statusPrefix} Initializing git repository for ${external_pintor_default().blue(projectName)}...`;
|
|
120
126
|
}
|
|
121
127
|
function initializingGitForRepositoryFailed(gitCommand, gitArgs, code) {
|
|
122
128
|
return `${external_pintor_default().red('Error')} Command ${external_pintor_default().yellow(gitCommand)} ${external_pintor_default().yellow(gitArgs.join(' '))} failed.\n${external_pintor_default().red(`Exit code: ${external_pintor_default().yellow(String(code))}`)}\n${external_pintor_default().red('Next step: run the command manually to inspect the error.')}`;
|
|
@@ -128,7 +134,7 @@ function initializingGitForRepositoryError(projectName, error) {
|
|
|
128
134
|
return `${external_pintor_default().red('Error')} Couldn't initialize ${external_pintor_default().yellow('git')} for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error?.message || error))}\n${external_pintor_default().red('Next step: retry initialization or create the repository manually.')}`;
|
|
129
135
|
}
|
|
130
136
|
function installingDependencies() {
|
|
131
|
-
return
|
|
137
|
+
return `${statusPrefix} Installing dependencies (this may take a moment)...`;
|
|
132
138
|
}
|
|
133
139
|
function installingDependenciesFailed(gitCommand, gitArgs, code) {
|
|
134
140
|
return `${external_pintor_default().red('Error')} Command ${external_pintor_default().yellow(gitCommand)} ${external_pintor_default().yellow(gitArgs.join(' '))} failed.\n${external_pintor_default().red(`Exit code: ${external_pintor_default().yellow(String(code))}`)}\n${external_pintor_default().red('Next step: run the command manually to inspect the error.')}`;
|
|
@@ -140,28 +146,28 @@ function cantInstallDependencies(projectName, error) {
|
|
|
140
146
|
return `${external_pintor_default().red('Error')} Couldn't install dependencies for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error?.message || error))}\n${external_pintor_default().red('Next step: check your package manager settings, then try again.')}`;
|
|
141
147
|
}
|
|
142
148
|
function writingPackageJsonMetadata() {
|
|
143
|
-
return
|
|
149
|
+
return `${statusPrefix} Writing ${external_pintor_default().yellow('package.json')}...`;
|
|
144
150
|
}
|
|
145
151
|
function writingPackageJsonMetadataError(projectName, error) {
|
|
146
152
|
return `${external_pintor_default().red('Error')} Couldn't write ${external_pintor_default().yellow('package.json')} for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: check file permissions, then try again.')}`;
|
|
147
153
|
}
|
|
148
154
|
function writingManifestJsonMetadata() {
|
|
149
|
-
return
|
|
155
|
+
return `${statusPrefix} Writing ${external_pintor_default().yellow('manifest.json')}...`;
|
|
150
156
|
}
|
|
151
157
|
function writingManifestJsonMetadataError(projectName, error) {
|
|
152
158
|
return `${external_pintor_default().red('Error')} Couldn't write ${external_pintor_default().yellow('manifest.json')} for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: check file permissions, then try again.')}`;
|
|
153
159
|
}
|
|
154
160
|
function writingReadmeMetaData() {
|
|
155
|
-
return
|
|
161
|
+
return `${statusPrefix} Writing ${external_pintor_default().yellow('README.md')}...`;
|
|
156
162
|
}
|
|
157
163
|
function writingGitIgnore() {
|
|
158
|
-
return
|
|
164
|
+
return `${statusPrefix} Writing ${external_pintor_default().yellow('.gitignore')}...`;
|
|
159
165
|
}
|
|
160
166
|
function writingReadmeMetaDataEError(projectName, error) {
|
|
161
167
|
return `${external_pintor_default().red('Error')} Couldn't write ${external_pintor_default().yellow('README.md')} for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: check file permissions, then try again.')}`;
|
|
162
168
|
}
|
|
163
169
|
function folderExists(projectName) {
|
|
164
|
-
return
|
|
170
|
+
return `${statusPrefix} Ensuring ${external_pintor_default().blue(projectName)} exists...`;
|
|
165
171
|
}
|
|
166
172
|
function writingDirectoryError(error) {
|
|
167
173
|
return `${external_pintor_default().red('Error')} Couldn't check directory writability.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: check the path and permissions, then try again.')}`;
|
|
@@ -170,9 +176,6 @@ function cantSetupBuiltInTests(projectName, error) {
|
|
|
170
176
|
return `${external_pintor_default().red('Error')} Couldn't set up built-in tests for ${external_pintor_default().yellow(projectName)}.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: run the setup step again or skip tests.')}`;
|
|
171
177
|
}
|
|
172
178
|
const promises_namespaceObject = require("fs/promises");
|
|
173
|
-
const external_url_namespaceObject = require("url");
|
|
174
|
-
const utils_filename = (0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__);
|
|
175
|
-
const utils_dirname = external_path_namespaceObject.dirname(utils_filename);
|
|
176
179
|
async function copyDirectoryWithSymlinks(source, destination) {
|
|
177
180
|
const entries = await promises_namespaceObject.readdir(source, {
|
|
178
181
|
withFileTypes: true
|
|
@@ -221,26 +224,7 @@ async function moveDirectoryContents(source, destination) {
|
|
|
221
224
|
});
|
|
222
225
|
}
|
|
223
226
|
async function getInstallCommand() {
|
|
224
|
-
|
|
225
|
-
let command = 'npm';
|
|
226
|
-
if (process.env.npm_config_user_agent) {
|
|
227
|
-
if (process.env.npm_config_user_agent.includes('pnpm')) return 'pnpm';
|
|
228
|
-
}
|
|
229
|
-
switch(pm?.name){
|
|
230
|
-
case 'yarn':
|
|
231
|
-
command = 'yarn';
|
|
232
|
-
break;
|
|
233
|
-
case 'pnpm':
|
|
234
|
-
command = 'pnpm';
|
|
235
|
-
break;
|
|
236
|
-
default:
|
|
237
|
-
command = 'npm';
|
|
238
|
-
}
|
|
239
|
-
return command;
|
|
240
|
-
}
|
|
241
|
-
function getTemplatePath(workingDir) {
|
|
242
|
-
const templatesDir = external_path_namespaceObject.resolve(utils_dirname, '..', 'template');
|
|
243
|
-
return external_path_namespaceObject.resolve(workingDir, templatesDir);
|
|
227
|
+
return detectPackageManagerFromEnv();
|
|
244
228
|
}
|
|
245
229
|
async function isDirectoryWriteable(directory, projectName) {
|
|
246
230
|
try {
|
|
@@ -254,9 +238,6 @@ async function isDirectoryWriteable(directory, projectName) {
|
|
|
254
238
|
return false;
|
|
255
239
|
}
|
|
256
240
|
}
|
|
257
|
-
function isExternalTemplate(_templateName) {
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
241
|
function isTypeScriptTemplate(templateName) {
|
|
261
242
|
return templateName.includes("typescript") || templateName.includes('react') || templateName.includes('preact') || templateName.includes('svelte') || templateName.includes('solid');
|
|
262
243
|
}
|
|
@@ -287,6 +268,7 @@ async function createDirectory(projectPath, projectName) {
|
|
|
287
268
|
throw new Error(createDirectoryError(projectName, error));
|
|
288
269
|
}
|
|
289
270
|
}
|
|
271
|
+
const external_url_namespaceObject = require("url");
|
|
290
272
|
const external_os_namespaceObject = require("os");
|
|
291
273
|
const external_axios_namespaceObject = require("axios");
|
|
292
274
|
var external_axios_default = /*#__PURE__*/ __webpack_require__.n(external_axios_namespaceObject);
|
|
@@ -397,9 +379,8 @@ const extensionJsPackageJsonScripts = {
|
|
|
397
379
|
'build:firefox': 'development' === process.env.EXTENSION_ENV ? 'node node_modules/extension build --browser firefox' : 'extension build --browser firefox',
|
|
398
380
|
'build:edge': 'development' === process.env.EXTENSION_ENV ? 'node node_modules/extension build --browser edge' : 'extension build --browser edge'
|
|
399
381
|
};
|
|
400
|
-
async function overridePackageJson(projectPath, projectName, { template, cliVersion }) {
|
|
401
|
-
const
|
|
402
|
-
const candidatePath = isExternalTemplate(template) ? external_path_namespaceObject.join(projectPath, 'package.json') : external_path_namespaceObject.join(templatePath, 'package.json');
|
|
382
|
+
async function overridePackageJson(projectPath, projectName, { template: _template, cliVersion }) {
|
|
383
|
+
const candidatePath = external_path_namespaceObject.join(projectPath, 'package.json');
|
|
403
384
|
let packageJson = {};
|
|
404
385
|
try {
|
|
405
386
|
const packageJsonContent = await promises_namespaceObject.readFile(candidatePath);
|
|
@@ -741,6 +722,15 @@ async function setupBuiltInTests(projectPath, projectName) {
|
|
|
741
722
|
throw error;
|
|
742
723
|
}
|
|
743
724
|
}
|
|
725
|
+
const external_module_namespaceObject = require("module");
|
|
726
|
+
async function preflightOptionalDependenciesForCreate(projectPath) {
|
|
727
|
+
try {
|
|
728
|
+
const requireFromProject = (0, external_module_namespaceObject.createRequire)(external_path_namespaceObject.join(projectPath, 'package.json'));
|
|
729
|
+
const develop = requireFromProject('extension-develop');
|
|
730
|
+
const preflight = develop?.preflightOptionalDependenciesForProject;
|
|
731
|
+
if ('function' == typeof preflight) await preflight(projectPath, 'development');
|
|
732
|
+
} catch {}
|
|
733
|
+
}
|
|
744
734
|
async function extensionCreate(projectNameInput, { cliVersion, template = 'init', install = false }) {
|
|
745
735
|
if (!projectNameInput) throw new Error(noProjectName());
|
|
746
736
|
if (projectNameInput.startsWith('http')) throw new Error(noUrlAllowed());
|
|
@@ -753,7 +743,10 @@ async function extensionCreate(projectNameInput, { cliVersion, template = 'init'
|
|
|
753
743
|
template,
|
|
754
744
|
cliVersion
|
|
755
745
|
});
|
|
756
|
-
if (install)
|
|
746
|
+
if (install) {
|
|
747
|
+
await installDependencies(projectPath, projectName);
|
|
748
|
+
await preflightOptionalDependenciesForCreate(projectPath);
|
|
749
|
+
}
|
|
757
750
|
await writeReadmeFile(projectPath, projectName);
|
|
758
751
|
await writeManifestJson(projectPath, projectName);
|
|
759
752
|
await initializeGitRepository(projectPath, projectName);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function preflightOptionalDependenciesForCreate(projectPath: string): Promise<void>;
|
|
@@ -2,5 +2,5 @@ interface OverridePackageJsonOptions {
|
|
|
2
2
|
template: string;
|
|
3
3
|
cliVersion?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function overridePackageJson(projectPath: string, projectName: string, { template, cliVersion }: OverridePackageJsonOptions): Promise<void>;
|
|
5
|
+
export declare function overridePackageJson(projectPath: string, projectName: string, { template: _template, cliVersion }: OverridePackageJsonOptions): Promise<void>;
|
|
6
6
|
export {};
|
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"name": "extension-create",
|
|
25
|
-
"version": "3.
|
|
25
|
+
"version": "3.2.0-next.2",
|
|
26
26
|
"description": "The standalone extension creation engine for Extension.js",
|
|
27
27
|
"author": {
|
|
28
28
|
"name": "Cezar Augusto",
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
"axios": "^1.13.2",
|
|
72
72
|
"cross-spawn": "^7.0.6",
|
|
73
73
|
"go-git-it": "^5.0.3",
|
|
74
|
-
"package-manager-detector": "^1.6.0",
|
|
75
74
|
"pintor": "0.3.0",
|
|
76
75
|
"tiny-glob": "^0.2.9"
|
|
77
76
|
},
|
package/dist/lib/types.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
declare namespace NodeJS {
|
|
2
|
-
interface ProcessEnv {
|
|
3
|
-
EXTENSION_BROWSER: 'chrome' | 'edge' | 'firefox' | 'chromium-based' | 'gecko-based';
|
|
4
|
-
EXTENSION_MODE: 'development' | 'production';
|
|
5
|
-
EXTENSION_PUBLIC_BROWSER: 'chrome' | 'edge' | 'firefox' | 'chromium-based' | 'gecko-based';
|
|
6
|
-
EXTENSION_PUBLIC_MODE: 'development' | 'production';
|
|
7
|
-
EXTENSION_PUBLIC_DESCRIPTION_TEXT: string;
|
|
8
|
-
EXTENSION_PUBLIC_LLM_API_KEY: string;
|
|
9
|
-
EXTENSION_ENV: 'development' | 'production';
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
interface ImportMetaEnv {
|
|
13
|
-
EXTENSION_BROWSER: NodeJS.ProcessEnv['EXTENSION_BROWSER'];
|
|
14
|
-
EXTENSION_MODE: NodeJS.ProcessEnv['EXTENSION_MODE'];
|
|
15
|
-
EXTENSION_PUBLIC_BROWSER: NodeJS.ProcessEnv['EXTENSION_BROWSER'];
|
|
16
|
-
EXTENSION_PUBLIC_MODE: NodeJS.ProcessEnv['EXTENSION_MODE'];
|
|
17
|
-
[key: string]: string | undefined;
|
|
18
|
-
}
|
|
19
|
-
interface ImportMeta {
|
|
20
|
-
readonly env: ImportMetaEnv;
|
|
21
|
-
readonly webpackHot?: {
|
|
22
|
-
accept: (module?: string | string[], callback?: () => void) => void;
|
|
23
|
-
dispose: (callback: () => void) => void;
|
|
24
|
-
};
|
|
25
|
-
url: string;
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function importLocalTemplate(projectPath: string, projectName: string, template: string): Promise<void>;
|