soso-ppm 2.4.8
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/.github/workflows/npm-publish.yaml +24 -0
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/bin/soso.js +78 -0
- package/lib/cache.js +196 -0
- package/lib/commands/clean.js +22 -0
- package/lib/commands/info.js +67 -0
- package/lib/commands/install.js +220 -0
- package/lib/commands/publish.js +143 -0
- package/lib/commands/update.js +111 -0
- package/lib/config.js +126 -0
- package/lib/lockfile.js +136 -0
- package/lib/resolver.js +139 -0
- package/lib/utils/git.js +136 -0
- package/lib/utils/help.js +53 -0
- package/lib/utils/logger.js +50 -0
- package/package.json +39 -0
package/lib/utils/git.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const { debug } = require('./logger');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Execute git command with proper Windows support
|
|
8
|
+
*/
|
|
9
|
+
function execGit(args, options = {}) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
debug(`Executing: git ${args.join(' ')}`);
|
|
12
|
+
|
|
13
|
+
const git = spawn('git', args, {
|
|
14
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
15
|
+
windowsHide: true,
|
|
16
|
+
...options
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
let stdout = '';
|
|
20
|
+
let stderr = '';
|
|
21
|
+
|
|
22
|
+
git.stdout.on('data', (data) => {
|
|
23
|
+
stdout += data.toString();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
git.stderr.on('data', (data) => {
|
|
27
|
+
stderr += data.toString();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
git.on('close', (code) => {
|
|
31
|
+
if (code !== 0) {
|
|
32
|
+
reject(new Error(`Git command failed: ${stderr.trim() || stdout.trim()}`));
|
|
33
|
+
} else {
|
|
34
|
+
resolve(stdout.trim());
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
git.on('error', (error) => {
|
|
39
|
+
if (error.code === 'ENOENT') {
|
|
40
|
+
reject(new Error('Git is not installed or not in PATH'));
|
|
41
|
+
} else {
|
|
42
|
+
reject(error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Clone a git repository
|
|
50
|
+
*/
|
|
51
|
+
async function clone(url, destination, options = {}) {
|
|
52
|
+
const args = ['clone'];
|
|
53
|
+
|
|
54
|
+
if (options.shallow) {
|
|
55
|
+
args.push('--depth', '1');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (options.branch) {
|
|
59
|
+
args.push('--branch', options.branch);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
args.push(url, destination);
|
|
63
|
+
|
|
64
|
+
await execGit(args);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Fetch tags from remote
|
|
69
|
+
*/
|
|
70
|
+
async function fetchTags(cwd) {
|
|
71
|
+
await execGit(['fetch', '--tags'], { cwd });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* List all tags
|
|
76
|
+
*/
|
|
77
|
+
async function listTags(cwd) {
|
|
78
|
+
const output = await execGit(['tag', '-l'], { cwd });
|
|
79
|
+
return output.split('\n').filter(tag => tag.trim());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Checkout a specific tag
|
|
84
|
+
*/
|
|
85
|
+
async function checkoutTag(tag, cwd) {
|
|
86
|
+
await execGit(['checkout', tag], { cwd });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Create an annotated tag
|
|
91
|
+
*/
|
|
92
|
+
async function createTag(tag, message, cwd) {
|
|
93
|
+
await execGit(['tag', '-a', tag, '-m', message], { cwd });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Push tags to remote
|
|
98
|
+
*/
|
|
99
|
+
async function pushTags(cwd) {
|
|
100
|
+
await execGit(['push', '--tags'], { cwd });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Check if working directory is clean
|
|
105
|
+
*/
|
|
106
|
+
async function isClean(cwd) {
|
|
107
|
+
const output = await execGit(['status', '--porcelain'], { cwd });
|
|
108
|
+
return output.length === 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get current commit hash
|
|
113
|
+
*/
|
|
114
|
+
async function getCurrentCommit(cwd) {
|
|
115
|
+
return await execGit(['rev-parse', 'HEAD'], { cwd });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Archive repository at specific ref
|
|
120
|
+
*/
|
|
121
|
+
async function archive(ref, destination, cwd) {
|
|
122
|
+
await execGit(['archive', '--format=tar', `--output=${destination}`, ref], { cwd });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = {
|
|
126
|
+
execGit,
|
|
127
|
+
clone,
|
|
128
|
+
fetchTags,
|
|
129
|
+
listTags,
|
|
130
|
+
checkoutTag,
|
|
131
|
+
createTag,
|
|
132
|
+
pushTags,
|
|
133
|
+
isClean,
|
|
134
|
+
getCurrentCommit,
|
|
135
|
+
archive
|
|
136
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
function printVersion() {
|
|
8
|
+
const pkgPath = path.join(__dirname, '../../package.json');
|
|
9
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
10
|
+
console.log(`soso v${pkg.version}`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function printHelp() {
|
|
14
|
+
console.log(`
|
|
15
|
+
${chalk.bold('SOSO')} - Private Package Manager
|
|
16
|
+
|
|
17
|
+
${chalk.bold('USAGE')}
|
|
18
|
+
soso <command> [options]
|
|
19
|
+
|
|
20
|
+
${chalk.bold('COMMANDS')}
|
|
21
|
+
${chalk.cyan('install')} [package] Install dependencies (or specific package)
|
|
22
|
+
${chalk.cyan('publish')} Publish current package to registry
|
|
23
|
+
${chalk.cyan('update')} [package] Update dependencies (or specific package)
|
|
24
|
+
${chalk.cyan('info')} <package> Show package information
|
|
25
|
+
${chalk.cyan('cache clean')} Clear the package cache
|
|
26
|
+
${chalk.cyan('version')} Show version number
|
|
27
|
+
${chalk.cyan('help')} Show this help message
|
|
28
|
+
|
|
29
|
+
${chalk.bold('OPTIONS')}
|
|
30
|
+
${chalk.cyan('--debug, -d')} Enable debug output
|
|
31
|
+
|
|
32
|
+
${chalk.bold('EXAMPLES')}
|
|
33
|
+
${chalk.gray('# Install all dependencies')}
|
|
34
|
+
soso install
|
|
35
|
+
|
|
36
|
+
${chalk.gray('# Install specific package')}
|
|
37
|
+
soso install @soso/utils
|
|
38
|
+
|
|
39
|
+
${chalk.gray('# Publish current package')}
|
|
40
|
+
soso publish
|
|
41
|
+
|
|
42
|
+
${chalk.gray('# Show package info')}
|
|
43
|
+
soso info @soso/logger
|
|
44
|
+
|
|
45
|
+
${chalk.gray('# Clear cache')}
|
|
46
|
+
soso cache clean
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
printVersion,
|
|
52
|
+
printHelp
|
|
53
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
let debugEnabled = false;
|
|
6
|
+
|
|
7
|
+
function enableDebug() {
|
|
8
|
+
debugEnabled = true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function log(message) {
|
|
12
|
+
console.log(message);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function success(message) {
|
|
16
|
+
console.log(chalk.green('✓') + ' ' + message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function error(message) {
|
|
20
|
+
console.error(chalk.red('✗') + ' ' + message);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function warn(message) {
|
|
24
|
+
console.warn(chalk.yellow('⚠') + ' ' + message);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function info(message) {
|
|
28
|
+
console.log(chalk.blue('ℹ') + ' ' + message);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function debug(message) {
|
|
32
|
+
if (debugEnabled) {
|
|
33
|
+
console.log(chalk.gray('[DEBUG]') + ' ' + message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function section(title) {
|
|
38
|
+
console.log('\n' + chalk.bold(title));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
enableDebug,
|
|
43
|
+
log,
|
|
44
|
+
success,
|
|
45
|
+
error,
|
|
46
|
+
warn,
|
|
47
|
+
info,
|
|
48
|
+
debug,
|
|
49
|
+
section
|
|
50
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "soso-ppm",
|
|
3
|
+
"version": "2.4.8",
|
|
4
|
+
"description": "Package manager made using nodejs",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"soso": "bin/soso.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node test/run-tests.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"package-manager",
|
|
14
|
+
"private",
|
|
15
|
+
"registry",
|
|
16
|
+
"npm"
|
|
17
|
+
],
|
|
18
|
+
"author": "Nitogx",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/Nitogx/soso-ppm.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/Nitogx/soso-ppm/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/Nitogx/soso-ppm#readme",
|
|
29
|
+
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"semver": "^7.5.4",
|
|
32
|
+
"chalk": "^4.1.2",
|
|
33
|
+
"tar": "^6.2.0",
|
|
34
|
+
"@soso/utils": "*"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=14.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|