extension-create 3.1.1 → 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.
@@ -0,0 +1,3 @@
1
+ type PackageManagerName = 'pnpm' | 'yarn' | 'npm';
2
+ export declare function detectPackageManagerFromEnv(): PackageManagerName;
3
+ export {};
@@ -1,5 +1,5 @@
1
1
  export declare function copyDirectoryWithSymlinks(source: string, destination: string): Promise<void>;
2
2
  export declare function moveDirectoryContents(source: string, destination: string): Promise<void>;
3
- export declare function getInstallCommand(): Promise<string>;
3
+ export declare function getInstallCommand(): Promise<"pnpm" | "yarn" | "npm">;
4
4
  export declare function isDirectoryWriteable(directory: string, projectName: string): Promise<boolean>;
5
5
  export declare function isTypeScriptTemplate(templateName: string): boolean;
package/dist/module.js CHANGED
@@ -42,7 +42,17 @@ 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
- const external_package_manager_detector_namespaceObject = require("package-manager-detector");
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
+ }
46
56
  const statusPrefix = external_pintor_default().brightBlue('►►►');
47
57
  function destinationNotWriteable(workingDir) {
48
58
  const workingDirFolder = external_path_namespaceObject.basename(workingDir);
@@ -66,10 +76,10 @@ function noUrlAllowed() {
66
76
  }
67
77
  async function successfullInstall(projectPath, projectName, depsInstalled) {
68
78
  const relativePath = external_path_namespaceObject.relative(process.cwd(), projectPath);
69
- const pm = await (0, external_package_manager_detector_namespaceObject.detect)();
79
+ const pm = detectPackageManagerFromEnv();
70
80
  let command = 'npm run';
71
81
  let installCmd = 'npm install';
72
- switch(pm?.name){
82
+ switch(pm){
73
83
  case 'yarn':
74
84
  command = 'yarn dev';
75
85
  installCmd = 'yarn';
@@ -82,12 +92,6 @@ async function successfullInstall(projectPath, projectName, depsInstalled) {
82
92
  command = 'npm run dev';
83
93
  installCmd = 'npm install';
84
94
  }
85
- if (process.env.npm_config_user_agent) {
86
- if (process.env.npm_config_user_agent.includes('pnpm')) {
87
- command = 'pnpm dev';
88
- installCmd = 'pnpm install';
89
- }
90
- }
91
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`;
92
96
  const depsNote = depsInstalled ? `\n${external_pintor_default().gray('Dependencies installed. You can start developing now.')}\n` : '\n';
93
97
  return `${statusPrefix} ${external_pintor_default().green('Created')} ${external_pintor_default().blue(projectName)}\n\nNext steps:\n\n` + steps + depsNote;
@@ -220,22 +224,7 @@ async function moveDirectoryContents(source, destination) {
220
224
  });
221
225
  }
222
226
  async function getInstallCommand() {
223
- const pm = await (0, external_package_manager_detector_namespaceObject.detect)();
224
- let command = 'npm';
225
- if (process.env.npm_config_user_agent) {
226
- if (process.env.npm_config_user_agent.includes('pnpm')) return 'pnpm';
227
- }
228
- switch(pm?.name){
229
- case 'yarn':
230
- command = 'yarn';
231
- break;
232
- case 'pnpm':
233
- command = 'pnpm';
234
- break;
235
- default:
236
- command = 'npm';
237
- }
238
- return command;
227
+ return detectPackageManagerFromEnv();
239
228
  }
240
229
  async function isDirectoryWriteable(directory, projectName) {
241
230
  try {
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "name": "extension-create",
25
- "version": "3.1.1",
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
  },