package-installer-cli 1.0.0 → 1.2.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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/dist/commands/add.js +7 -49
  4. data/dist/index.js +17 -10
  5. data/dist/utils/banner.js +3 -1
  6. data/dist/utils/cacheUtils.js +1 -1
  7. data/dist/utils/dashboard.js +1 -1
  8. data/dist/utils/dependencyInstaller.js +2 -46
  9. data/dist/utils/featureInstaller.js +158 -105
  10. data/dist/utils/languageConfig.js +169 -300
  11. data/dist/utils/pathResolver.js +179 -0
  12. data/dist/utils/prompts.js +5 -14
  13. data/dist/utils/templateCreator.js +3 -3
  14. data/dist/utils/templateResolver.js +8 -17
  15. data/dist/utils/types.js +2 -2
  16. data/dist/utils/ui.js +2 -2
  17. data/dist/utils/utils.js +20 -1
  18. data/lib/package_installer_cli.rb +1 -1
  19. data/templates/django/django-full-stack-template/django-project-template/deployment/docker/build.sh +0 -0
  20. data/templates/django/django-full-stack-template/django-project-template/deployment/docker/manage.py +0 -0
  21. data/templates/django/django-full-stack-template/django-project-template/src/compile-locale.sh +0 -0
  22. data/templates/django/django-full-stack-template/django-project-template/src/compile-sass.sh +0 -0
  23. data/templates/django/django-full-stack-template/django-project-template/src/manage.py +0 -0
  24. data/templates/django/django-inertia-svelte-template/django-inertia-svelte-template-starter/manage.py +0 -0
  25. data/templates/flask/flask-cookiecutter-advance-template/cookiecutter-docker.sh +0 -0
  26. data/templates/flask/flask-cookiecutter-advance-template/{{cookiecutter.app_name}}/autoapp.py +0 -0
  27. data/templates/flask/flask-project-template/apply.sh +0 -0
  28. data/templates/react-native/typescript/template/android/gradlew +0 -0
  29. data/templates/ruby/rails_7_esbuild_hotwire_tailwindcss_starter/bin/bundle +0 -0
  30. data/templates/ruby/rails_7_esbuild_hotwire_tailwindcss_starter/bin/dev +0 -0
  31. data/templates/ruby/rails_7_esbuild_hotwire_tailwindcss_starter/bin/docker-entrypoint +0 -0
  32. data/templates/ruby/rails_7_esbuild_hotwire_tailwindcss_starter/bin/rails +0 -0
  33. data/templates/ruby/rails_7_esbuild_hotwire_tailwindcss_starter/bin/rake +0 -0
  34. data/templates/ruby/rails_7_esbuild_hotwire_tailwindcss_starter/bin/setup +0 -0
  35. data/templates/ruby/ruby-on-rails-apis-template/bin/bundle +0 -0
  36. data/templates/ruby/ruby-on-rails-apis-template/bin/rails +0 -0
  37. data/templates/ruby/ruby-on-rails-apis-template/bin/rake +0 -0
  38. data/templates/ruby/ruby-on-rails-apis-template/bin/setup +0 -0
  39. data/templates/ruby/ruby-on-rails-apis-template/bin/spring +0 -0
  40. data/templates/ruby/ruby-on-rails-apis-template/bin/update +0 -0
  41. data/templates/ruby/ruby-on-rails-boilerplate-template/bin/bundle +0 -0
  42. data/templates/ruby/ruby-on-rails-boilerplate-template/bin/dev +0 -0
  43. data/templates/ruby/ruby-on-rails-boilerplate-template/bin/importmap +0 -0
  44. data/templates/ruby/ruby-on-rails-boilerplate-template/bin/rails +0 -0
  45. data/templates/ruby/ruby-on-rails-boilerplate-template/bin/rake +0 -0
  46. data/templates/ruby/ruby-on-rails-boilerplate-template/bin/setup +0 -0
  47. metadata +6 -5
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Path resolution utility for Package Installer CLI
3
+ * Centralized path resolution logic that works for both local development and global installations
4
+ */
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { fileURLToPath } from 'url';
8
+ /**
9
+ * Get the CLI installation root directory
10
+ * Works for both local development and global installations across multiple package managers
11
+ */
12
+ export function getCliRootPath() {
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+ // All possible package names across different package managers
16
+ const packageNames = [
17
+ '@0xshariq/package-installer', // npm
18
+ 'package-installer-cli', // PyPI, RubyGems, Rust crates
19
+ 'go_package_installer_cli' // Go (from github.com/0xshariq/go_package_installer_cli)
20
+ ];
21
+ // Method 1: Walk up the directory tree to find package.json with any of our package names
22
+ let currentDir = __dirname;
23
+ while (currentDir !== path.dirname(currentDir)) {
24
+ const packageJsonPath = path.join(currentDir, 'package.json');
25
+ if (fs.existsSync(packageJsonPath)) {
26
+ try {
27
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
28
+ if (packageNames.includes(packageJson.name)) {
29
+ return currentDir;
30
+ }
31
+ }
32
+ catch (error) {
33
+ // Continue searching
34
+ }
35
+ }
36
+ currentDir = path.dirname(currentDir);
37
+ }
38
+ // Method 2: Check if this is a local development environment
39
+ const localDevPath = path.resolve(__dirname, '..', '..');
40
+ if (fs.existsSync(path.join(localDevPath, 'package.json')) &&
41
+ fs.existsSync(path.join(localDevPath, 'features'))) {
42
+ try {
43
+ const packageJson = JSON.parse(fs.readFileSync(path.join(localDevPath, 'package.json'), 'utf-8'));
44
+ if (packageNames.includes(packageJson.name)) {
45
+ return localDevPath;
46
+ }
47
+ }
48
+ catch (error) {
49
+ // Continue to other methods
50
+ }
51
+ }
52
+ // Method 3: Try to resolve using require.resolve for npm installations
53
+ for (const packageName of packageNames) {
54
+ try {
55
+ const packageMainPath = require.resolve(`${packageName}/package.json`);
56
+ return path.dirname(packageMainPath);
57
+ }
58
+ catch (error) {
59
+ // Package not found in require cache, try next
60
+ }
61
+ }
62
+ // Method 4: Check common global installation paths for all package managers
63
+ const globalPaths = [];
64
+ // npm global paths
65
+ globalPaths.push(
66
+ // Linux/macOS npm global paths
67
+ '/usr/local/lib/node_modules/@0xshariq/package-installer', '/usr/lib/node_modules/@0xshariq/package-installer',
68
+ // User-specific npm global paths
69
+ path.join(process.env.HOME || '', '.npm-global/lib/node_modules/@0xshariq/package-installer'), path.join(process.env.HOME || '', '.npm/lib/node_modules/@0xshariq/package-installer'),
70
+ // Windows npm global paths
71
+ path.join(process.env.APPDATA || '', 'npm/node_modules/@0xshariq/package-installer'), path.join(process.env.ProgramFiles || '', 'nodejs/node_modules/@0xshariq/package-installer'));
72
+ // PyPI/pip global paths
73
+ if (process.env.HOME) {
74
+ globalPaths.push(
75
+ // Linux/macOS pip user install paths
76
+ path.join(process.env.HOME, '.local/lib/python*/site-packages/package-installer-cli'), path.join(process.env.HOME, '.local/bin/package-installer-cli'),
77
+ // System-wide pip install paths
78
+ '/usr/local/lib/python*/site-packages/package-installer-cli', '/usr/lib/python*/site-packages/package-installer-cli');
79
+ }
80
+ // RubyGems global paths
81
+ if (process.env.HOME) {
82
+ globalPaths.push(
83
+ // User gem installation paths
84
+ path.join(process.env.HOME, '.gem/ruby/*/gems/package-installer-cli-*'), path.join(process.env.HOME, '.local/share/gem/ruby/*/gems/package-installer-cli-*'),
85
+ // System gem installation paths
86
+ '/usr/local/lib/ruby/gems/*/gems/package-installer-cli-*', '/var/lib/gems/*/gems/package-installer-cli-*');
87
+ }
88
+ // Rust cargo global paths
89
+ if (process.env.HOME) {
90
+ globalPaths.push(path.join(process.env.HOME, '.cargo/bin/package-installer-cli'), path.join(process.env.HOME, '.cargo/registry/src/*/package-installer-cli-*'));
91
+ }
92
+ // Go global paths
93
+ const goPath = process.env.GOPATH || path.join(process.env.HOME || '', 'go');
94
+ globalPaths.push(path.join(goPath, 'bin/go_package_installer_cli'), path.join(goPath, 'bin/pi'), // In case the binary is named 'pi'
95
+ path.join(goPath, 'pkg/mod/github.com/0xshariq/go_package_installer_cli*'),
96
+ // Also check system-wide go installation paths
97
+ '/usr/local/bin/go_package_installer_cli', '/usr/local/bin/pi');
98
+ // Check all possible global paths
99
+ for (const globalPath of globalPaths) {
100
+ // Handle wildcard paths
101
+ if (globalPath.includes('*')) {
102
+ try {
103
+ const { execSync } = require('child_process');
104
+ const expandedPaths = execSync(`ls -d ${globalPath} 2>/dev/null || true`, { encoding: 'utf8' }).trim().split('\n').filter((p) => p);
105
+ for (const expandedPath of expandedPaths) {
106
+ if (fs.existsSync(expandedPath) && (fs.existsSync(path.join(expandedPath, 'features')) ||
107
+ fs.existsSync(path.join(path.dirname(expandedPath), 'features')))) {
108
+ return fs.existsSync(path.join(expandedPath, 'features')) ? expandedPath : path.dirname(expandedPath);
109
+ }
110
+ }
111
+ }
112
+ catch (error) {
113
+ // Continue to next path
114
+ }
115
+ }
116
+ else {
117
+ if (fs.existsSync(globalPath) && fs.existsSync(path.join(globalPath, 'features'))) {
118
+ return globalPath;
119
+ }
120
+ }
121
+ }
122
+ // Method 5: Check if npm prefix is available and use it (for npm installations)
123
+ try {
124
+ const { execSync } = require('child_process');
125
+ const npmPrefix = execSync('npm config get prefix', { encoding: 'utf8' }).trim();
126
+ const npmGlobalPath = path.join(npmPrefix, 'lib/node_modules/@0xshariq/package-installer');
127
+ if (fs.existsSync(npmGlobalPath) && fs.existsSync(path.join(npmGlobalPath, 'features'))) {
128
+ return npmGlobalPath;
129
+ }
130
+ }
131
+ catch (error) {
132
+ // npm not available or command failed
133
+ }
134
+ // Method 6: Check binary location and work backwards (for compiled languages like Go/Rust)
135
+ try {
136
+ const { execSync } = require('child_process');
137
+ const whichResult = execSync('which pi || which package-installer-cli || which go_package_installer_cli || echo ""', { encoding: 'utf8' }).trim();
138
+ if (whichResult) {
139
+ // Go up from binary location to find the package root
140
+ let binaryDir = path.dirname(whichResult);
141
+ while (binaryDir !== path.dirname(binaryDir)) {
142
+ if (fs.existsSync(path.join(binaryDir, 'features'))) {
143
+ return binaryDir;
144
+ }
145
+ binaryDir = path.dirname(binaryDir);
146
+ }
147
+ }
148
+ }
149
+ catch (error) {
150
+ // which command failed or not available
151
+ }
152
+ // Final fallback: use the local development path
153
+ console.warn('⚠️ Could not resolve CLI root path, using fallback');
154
+ return path.resolve(__dirname, '..', '..');
155
+ }
156
+ /**
157
+ * Get the path to the features directory
158
+ */
159
+ export function getFeaturesPath() {
160
+ return path.join(getCliRootPath(), 'features');
161
+ }
162
+ /**
163
+ * Get the path to the features.json file
164
+ */
165
+ export function getFeaturesJsonPath() {
166
+ return path.join(getFeaturesPath(), 'features.json');
167
+ }
168
+ /**
169
+ * Get the path to the templates directory
170
+ */
171
+ export function getTemplatesPath() {
172
+ return path.join(getCliRootPath(), 'templates');
173
+ }
174
+ /**
175
+ * Get the path to the package.json file
176
+ */
177
+ export function getPackageJsonPath() {
178
+ return path.join(getCliRootPath(), 'package.json');
179
+ }
@@ -1,22 +1,15 @@
1
1
  /**
2
- * User interaction prompts for Package Installer CLI v3.0.0
2
+ * User interaction prompts for Package Installer CLI v3.2.0
3
3
  * Handles framework selection and template configuration based on template.json
4
4
  */
5
5
  import inquirer from 'inquirer';
6
6
  import chalk from 'chalk';
7
7
  import fs from 'fs-extra';
8
8
  import path from 'path';
9
- import { fileURLToPath } from 'url';
10
- // Get CLI installation directory
11
- function getCLIDirectory() {
12
- const __filename = fileURLToPath(import.meta.url);
13
- const __dirname = path.dirname(__filename);
14
- // Go up from src/utils to root directory
15
- return path.resolve(__dirname, '..', '..');
16
- }
9
+ import { getCliRootPath, getFeaturesJsonPath } from './pathResolver.js';
17
10
  // Helper functions to read template.json
18
11
  function getTemplateConfig() {
19
- const cliDir = getCLIDirectory();
12
+ const cliDir = getCliRootPath();
20
13
  const templatePath = path.join(cliDir, 'template.json');
21
14
  if (!fs.existsSync(templatePath)) {
22
15
  throw new Error(`template.json not found at: ${templatePath}`);
@@ -275,8 +268,7 @@ export async function promptFeatureSelection() {
275
268
  return [];
276
269
  }
277
270
  // Get available feature categories from features.json
278
- const cliDir = getCLIDirectory();
279
- const featuresPath = path.join(cliDir, 'features', 'features.json');
271
+ const featuresPath = getFeaturesJsonPath();
280
272
  if (!fs.existsSync(featuresPath)) {
281
273
  console.log(chalk.yellow('⚠️ Features configuration not found'));
282
274
  return [];
@@ -302,8 +294,7 @@ export async function promptFeatureSelection() {
302
294
  * Specific feature provider selection
303
295
  */
304
296
  export async function promptFeatureProvider(category, framework) {
305
- const cliDir = getCLIDirectory();
306
- const featuresPath = path.join(cliDir, 'features', 'features.json');
297
+ const featuresPath = getFeaturesJsonPath();
307
298
  const featuresConfig = JSON.parse(fs.readFileSync(featuresPath, 'utf-8'));
308
299
  if (!featuresConfig[category]) {
309
300
  return null;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Template creation utilities for Package Installer CLI v3.0.0
2
+ * Template creation utilities for Package Installer CLI v3.2.0
3
3
  * Enhanced with features integration support
4
4
  */
5
5
  import fs from 'fs-extra';
@@ -329,11 +329,11 @@ async function initializeGitRepositoryForCreate(projectPath) {
329
329
  // Make initial commit
330
330
  try {
331
331
  gitSpinner.text = chalk.hex('#00d2d3')('Creating initial commit with gcommit...');
332
- await execAsync('gcommit "Initial commit from Package Installer CLI v3.0.0"', { cwd: projectPath });
332
+ await execAsync('gcommit "Initial commit from Package Installer CLI v3.2.0"', { cwd: projectPath });
333
333
  }
334
334
  catch {
335
335
  gitSpinner.text = chalk.hex('#00d2d3')('Creating initial commit with git commit...');
336
- await execAsync('git commit -m "Initial commit from Package Installer CLI v3.0.0"', { cwd: projectPath });
336
+ await execAsync('git commit -m "Initial commit from Package Installer CLI v3.2.0"', { cwd: projectPath });
337
337
  }
338
338
  gitSpinner.succeed(chalk.green('✅ Git repository initialized with initial commit'));
339
339
  }
@@ -4,17 +4,10 @@
4
4
  */
5
5
  import path from 'path';
6
6
  import fs from 'fs-extra';
7
- import { fileURLToPath } from 'url';
8
- // Get CLI installation directory
9
- function getCLIDirectory() {
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
- // Go up from src/utils to root directory
13
- return path.resolve(__dirname, '..', '..');
14
- }
7
+ import { getCliRootPath, getTemplatesPath } from './pathResolver.js';
15
8
  // Helper functions to read template.json
16
9
  function getTemplateConfig() {
17
- const cliDir = getCLIDirectory();
10
+ const cliDir = getCliRootPath();
18
11
  const templatePath = path.join(cliDir, 'template.json');
19
12
  if (!fs.existsSync(templatePath)) {
20
13
  throw new Error(`template.json not found at: ${templatePath}`);
@@ -50,14 +43,13 @@ export function generateTemplateName(framework, options) {
50
43
  parts.push('no-src');
51
44
  }
52
45
  }
53
- // Handle UI library
46
+ // Handle UI library - only add if actually selected (not "none")
47
+ // When UI is "none", templates simply omit the UI part from their names
54
48
  if (config.ui && config.ui.length > 0) {
55
49
  if (options.ui && options.ui !== 'none') {
56
50
  parts.push(options.ui);
57
51
  }
58
- else {
59
- parts.push('no-' + config.ui[0]);
60
- }
52
+ // For "none" selection, don't add any UI part to the template name
61
53
  }
62
54
  // Handle tailwind option
63
55
  if (config.options?.includes('tailwind')) {
@@ -84,8 +76,7 @@ export function generateTemplateName(framework, options) {
84
76
  */
85
77
  export function resolveTemplatePath(projectInfo) {
86
78
  const { framework, language, templateName } = projectInfo;
87
- const cliDir = getCLIDirectory();
88
- const templatesRoot = path.join(cliDir, 'templates');
79
+ const templatesRoot = getTemplatesPath();
89
80
  // Handle combination templates (like reactjs+expressjs+shadcn)
90
81
  if (framework.includes('+')) {
91
82
  const frameworkDir = framework.replace(/\+/g, '-');
@@ -144,8 +135,8 @@ export function templateExists(templatePath) {
144
135
  * Get all available templates for a framework
145
136
  */
146
137
  export function getFrameworkTemplates(framework) {
147
- const cliDir = getCLIDirectory();
148
- const frameworkPath = path.join(cliDir, 'templates', framework);
138
+ const templatesRoot = getTemplatesPath();
139
+ const frameworkPath = path.join(templatesRoot, framework);
149
140
  if (!fs.existsSync(frameworkPath)) {
150
141
  return [];
151
142
  }
data/dist/utils/types.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Type definitions for Package Installer CLI v3.0.0
3
- * Enhanced type system without database logic, focused on modern template structure
2
+ * Type definitions for Package Installer CLI v3.2.0
3
+ * Comprehensive type system for enhanced CLI functionality
4
4
  */
5
5
  export {};
data/dist/utils/ui.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * UI and display utilities for Package Installer CLI v3.0.0
3
- * Enhanced with modern styling, progress indicators, and better user experience
2
+ * UI and display utilities for Package Installer CLI v3.2.0
3
+ * Enhanced user interface components and styling utilities
4
4
  */
5
5
  import chalk from 'chalk';
6
6
  import figlet from 'figlet';
data/dist/utils/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Enhanced utility functions for Package Installer CLI v3.0.0
2
+ * Enhanced utility functions for Package Installer CLI v3.2.0
3
3
  * Comprehensive utilities for project management, validation, and operations
4
4
  */
5
5
  import chalk from 'chalk';
@@ -8,7 +8,26 @@ import * as fs from 'fs';
8
8
  import * as crypto from 'crypto';
9
9
  import { promisify } from 'util';
10
10
  import { exec } from 'child_process';
11
+ import { fileURLToPath } from 'url';
12
+ import { getPackageJsonPath } from './pathResolver.js';
11
13
  const execAsync = promisify(exec);
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = path.dirname(__filename);
16
+ /**
17
+ * Get the current version from package.json
18
+ */
19
+ export function getPackageVersion() {
20
+ try {
21
+ const packageJsonPath = getPackageJsonPath();
22
+ const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8');
23
+ const packageJson = JSON.parse(packageJsonContent);
24
+ return packageJson.version || '3.4.0';
25
+ }
26
+ catch (error) {
27
+ console.warn('Warning: Could not read version from package.json, using fallback version');
28
+ return '3.2.0';
29
+ }
30
+ }
12
31
  /**
13
32
  * Enhanced string utilities
14
33
  */
@@ -4,7 +4,7 @@ require 'open3'
4
4
  require 'json'
5
5
 
6
6
  module PackageInstallerCli
7
- VERSION = "3.2.0"
7
+ VERSION = "1.2.0"
8
8
 
9
9
  class << self
10
10
  def run(args = ARGV)
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: package-installer-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sharique
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-22 00:00:00.000000000 Z
11
+ date: 2025-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -105,6 +105,7 @@ files:
105
105
  - dist/utils/featureInstaller.js
106
106
  - dist/utils/historyManager.js
107
107
  - dist/utils/languageConfig.js
108
+ - dist/utils/pathResolver.js
108
109
  - dist/utils/prompts.js
109
110
  - dist/utils/templateCreator.js
110
111
  - dist/utils/templateResolver.js
@@ -2984,8 +2985,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2984
2985
  - !ruby/object:Gem::Version
2985
2986
  version: '0'
2986
2987
  requirements: []
2987
- rubygems_version: 3.1.2
2988
- signing_key:
2988
+ rubygems_version: 3.4.20
2989
+ signing_key:
2989
2990
  specification_version: 4
2990
2991
  summary: A cross-platform, interactive CLI to scaffold modern web app templates
2991
2992
  test_files: []