extension-create 3.1.0-next.8 → 3.1.1
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/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
3
|
export declare function getInstallCommand(): Promise<string>;
|
|
5
|
-
export declare function getTemplatePath(workingDir: string): string;
|
|
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
|
@@ -43,6 +43,7 @@ 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
|
const external_package_manager_detector_namespaceObject = require("package-manager-detector");
|
|
46
|
+
const statusPrefix = external_pintor_default().brightBlue('►►►');
|
|
46
47
|
function destinationNotWriteable(workingDir) {
|
|
47
48
|
const workingDirFolder = external_path_namespaceObject.basename(workingDir);
|
|
48
49
|
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)}`;
|
|
@@ -88,35 +89,36 @@ async function successfullInstall(projectPath, projectName, depsInstalled) {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
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
|
-
|
|
92
|
+
const depsNote = depsInstalled ? `\n${external_pintor_default().gray('Dependencies installed. You can start developing now.')}\n` : '\n';
|
|
93
|
+
return `${statusPrefix} ${external_pintor_default().green('Created')} ${external_pintor_default().blue(projectName)}\n\nNext steps:\n\n` + steps + depsNote;
|
|
92
94
|
}
|
|
93
95
|
function startingNewExtension(projectName) {
|
|
94
|
-
return
|
|
96
|
+
return `${statusPrefix} Creating ${external_pintor_default().blue(projectName)}...`;
|
|
95
97
|
}
|
|
96
98
|
function checkingIfPathIsWriteable() {
|
|
97
|
-
return
|
|
99
|
+
return `${statusPrefix} Checking if the destination path is writable...`;
|
|
98
100
|
}
|
|
99
101
|
function scanningPossiblyConflictingFiles() {
|
|
100
|
-
return
|
|
102
|
+
return `${statusPrefix} Scanning for conflicting files...`;
|
|
101
103
|
}
|
|
102
104
|
function createDirectoryError(projectName, error) {
|
|
103
105
|
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
106
|
}
|
|
105
107
|
function writingTypeDefinitions(projectName) {
|
|
106
|
-
return
|
|
108
|
+
return `${statusPrefix} Writing type definitions for ${external_pintor_default().blue(projectName)}...`;
|
|
107
109
|
}
|
|
108
110
|
function writingTypeDefinitionsError(error) {
|
|
109
111
|
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
112
|
}
|
|
111
113
|
function installingFromTemplate(projectName, templateName) {
|
|
112
|
-
if ('init' === templateName) return
|
|
113
|
-
return
|
|
114
|
+
if ('init' === templateName) return `${statusPrefix} Installing ${external_pintor_default().blue(projectName)}...`;
|
|
115
|
+
return `${statusPrefix} Installing ${external_pintor_default().blue(projectName)} from template ${external_pintor_default().yellow(templateName)}...`;
|
|
114
116
|
}
|
|
115
117
|
function installingFromTemplateError(projectName, template, error) {
|
|
116
118
|
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
119
|
}
|
|
118
120
|
function initializingGitForRepository(projectName) {
|
|
119
|
-
return
|
|
121
|
+
return `${statusPrefix} Initializing git repository for ${external_pintor_default().blue(projectName)}...`;
|
|
120
122
|
}
|
|
121
123
|
function initializingGitForRepositoryFailed(gitCommand, gitArgs, code) {
|
|
122
124
|
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 +130,7 @@ function initializingGitForRepositoryError(projectName, error) {
|
|
|
128
130
|
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
131
|
}
|
|
130
132
|
function installingDependencies() {
|
|
131
|
-
return
|
|
133
|
+
return `${statusPrefix} Installing dependencies (this may take a moment)...`;
|
|
132
134
|
}
|
|
133
135
|
function installingDependenciesFailed(gitCommand, gitArgs, code) {
|
|
134
136
|
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 +142,28 @@ function cantInstallDependencies(projectName, error) {
|
|
|
140
142
|
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
143
|
}
|
|
142
144
|
function writingPackageJsonMetadata() {
|
|
143
|
-
return
|
|
145
|
+
return `${statusPrefix} Writing ${external_pintor_default().yellow('package.json')}...`;
|
|
144
146
|
}
|
|
145
147
|
function writingPackageJsonMetadataError(projectName, error) {
|
|
146
148
|
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
149
|
}
|
|
148
150
|
function writingManifestJsonMetadata() {
|
|
149
|
-
return
|
|
151
|
+
return `${statusPrefix} Writing ${external_pintor_default().yellow('manifest.json')}...`;
|
|
150
152
|
}
|
|
151
153
|
function writingManifestJsonMetadataError(projectName, error) {
|
|
152
154
|
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
155
|
}
|
|
154
156
|
function writingReadmeMetaData() {
|
|
155
|
-
return
|
|
157
|
+
return `${statusPrefix} Writing ${external_pintor_default().yellow('README.md')}...`;
|
|
156
158
|
}
|
|
157
159
|
function writingGitIgnore() {
|
|
158
|
-
return
|
|
160
|
+
return `${statusPrefix} Writing ${external_pintor_default().yellow('.gitignore')}...`;
|
|
159
161
|
}
|
|
160
162
|
function writingReadmeMetaDataEError(projectName, error) {
|
|
161
163
|
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
164
|
}
|
|
163
165
|
function folderExists(projectName) {
|
|
164
|
-
return
|
|
166
|
+
return `${statusPrefix} Ensuring ${external_pintor_default().blue(projectName)} exists...`;
|
|
165
167
|
}
|
|
166
168
|
function writingDirectoryError(error) {
|
|
167
169
|
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 +172,6 @@ function cantSetupBuiltInTests(projectName, error) {
|
|
|
170
172
|
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
173
|
}
|
|
172
174
|
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
175
|
async function copyDirectoryWithSymlinks(source, destination) {
|
|
177
176
|
const entries = await promises_namespaceObject.readdir(source, {
|
|
178
177
|
withFileTypes: true
|
|
@@ -238,10 +237,6 @@ async function getInstallCommand() {
|
|
|
238
237
|
}
|
|
239
238
|
return command;
|
|
240
239
|
}
|
|
241
|
-
function getTemplatePath(workingDir) {
|
|
242
|
-
const templatesDir = external_path_namespaceObject.resolve(utils_dirname, '..', 'template');
|
|
243
|
-
return external_path_namespaceObject.resolve(workingDir, templatesDir);
|
|
244
|
-
}
|
|
245
240
|
async function isDirectoryWriteable(directory, projectName) {
|
|
246
241
|
try {
|
|
247
242
|
console.log(folderExists(projectName));
|
|
@@ -254,9 +249,6 @@ async function isDirectoryWriteable(directory, projectName) {
|
|
|
254
249
|
return false;
|
|
255
250
|
}
|
|
256
251
|
}
|
|
257
|
-
function isExternalTemplate(_templateName) {
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
252
|
function isTypeScriptTemplate(templateName) {
|
|
261
253
|
return templateName.includes("typescript") || templateName.includes('react') || templateName.includes('preact') || templateName.includes('svelte') || templateName.includes('solid');
|
|
262
254
|
}
|
|
@@ -287,6 +279,7 @@ async function createDirectory(projectPath, projectName) {
|
|
|
287
279
|
throw new Error(createDirectoryError(projectName, error));
|
|
288
280
|
}
|
|
289
281
|
}
|
|
282
|
+
const external_url_namespaceObject = require("url");
|
|
290
283
|
const external_os_namespaceObject = require("os");
|
|
291
284
|
const external_axios_namespaceObject = require("axios");
|
|
292
285
|
var external_axios_default = /*#__PURE__*/ __webpack_require__.n(external_axios_namespaceObject);
|
|
@@ -397,9 +390,8 @@ const extensionJsPackageJsonScripts = {
|
|
|
397
390
|
'build:firefox': 'development' === process.env.EXTENSION_ENV ? 'node node_modules/extension build --browser firefox' : 'extension build --browser firefox',
|
|
398
391
|
'build:edge': 'development' === process.env.EXTENSION_ENV ? 'node node_modules/extension build --browser edge' : 'extension build --browser edge'
|
|
399
392
|
};
|
|
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');
|
|
393
|
+
async function overridePackageJson(projectPath, projectName, { template: _template, cliVersion }) {
|
|
394
|
+
const candidatePath = external_path_namespaceObject.join(projectPath, 'package.json');
|
|
403
395
|
let packageJson = {};
|
|
404
396
|
try {
|
|
405
397
|
const packageJsonContent = await promises_namespaceObject.readFile(candidatePath);
|
|
@@ -741,6 +733,15 @@ async function setupBuiltInTests(projectPath, projectName) {
|
|
|
741
733
|
throw error;
|
|
742
734
|
}
|
|
743
735
|
}
|
|
736
|
+
const external_module_namespaceObject = require("module");
|
|
737
|
+
async function preflightOptionalDependenciesForCreate(projectPath) {
|
|
738
|
+
try {
|
|
739
|
+
const requireFromProject = (0, external_module_namespaceObject.createRequire)(external_path_namespaceObject.join(projectPath, 'package.json'));
|
|
740
|
+
const develop = requireFromProject('extension-develop');
|
|
741
|
+
const preflight = develop?.preflightOptionalDependenciesForProject;
|
|
742
|
+
if ('function' == typeof preflight) await preflight(projectPath, 'development');
|
|
743
|
+
} catch {}
|
|
744
|
+
}
|
|
744
745
|
async function extensionCreate(projectNameInput, { cliVersion, template = 'init', install = false }) {
|
|
745
746
|
if (!projectNameInput) throw new Error(noProjectName());
|
|
746
747
|
if (projectNameInput.startsWith('http')) throw new Error(noUrlAllowed());
|
|
@@ -753,7 +754,10 @@ async function extensionCreate(projectNameInput, { cliVersion, template = 'init'
|
|
|
753
754
|
template,
|
|
754
755
|
cliVersion
|
|
755
756
|
});
|
|
756
|
-
if (install)
|
|
757
|
+
if (install) {
|
|
758
|
+
await installDependencies(projectPath, projectName);
|
|
759
|
+
await preflightOptionalDependenciesForCreate(projectPath);
|
|
760
|
+
}
|
|
757
761
|
await writeReadmeFile(projectPath, projectName);
|
|
758
762
|
await writeManifestJson(projectPath, projectName);
|
|
759
763
|
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
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>;
|