@nan0web/release 1.0.1 → 1.0.3
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/README.md +24 -42
- package/bin/nan0release.js +27 -42
- package/package.json +48 -42
- package/project.yaml +79 -0
- package/src/README.md.js +90 -93
- package/src/Release/Document.js +13 -19
- package/src/Release/MarkdownToTest.js +35 -33
- package/src/Release/Person.js +3 -8
- package/src/Release/Scanner.js +179 -0
- package/src/Release.js +19 -12
- package/src/Team.js +9 -9
- package/src/architecture/ProjectManagementAsCode.js +8 -8
- package/src/cli/index.js +9 -0
- package/src/co/AppCommandOptions.js +4 -6
- package/src/commands/CloseCommand.js +67 -0
- package/src/commands/Command.js +48 -0
- package/src/commands/DepsCommand.js +143 -0
- package/src/commands/InitCommand.js +48 -56
- package/src/commands/PublishCommand.js +80 -119
- package/src/commands/SpecCommand.js +41 -0
- package/src/commands/StatusCommand.js +26 -0
- package/src/db/ReleaseDB.js +5 -5
- package/src/index.js +18 -0
- package/src/ui/cli/ReleaseCLi.js +52 -0
- package/src/utils/runSpawn.js +0 -0
- package/types/Release/Document.d.ts +2 -2
- package/types/Release/Person.d.ts +3 -3
- package/types/Release/Scanner.d.ts +90 -0
- package/types/Release.d.ts +37 -33
- package/types/ReleaseCLI.d.ts +29 -28
- package/types/Team.d.ts +3 -3
- package/types/architecture/ProjectManagementAsCode.d.ts +1 -1
- package/types/cli/index.d.ts +2 -0
- package/types/co/AppCommandMessage.d.ts +10 -11
- package/types/co/AppCommandOptions.d.ts +1 -2
- package/types/commands/BaseCommand.d.ts +23 -0
- package/types/commands/ChatCommand.d.ts +9 -9
- package/types/commands/ChatMessage.d.ts +36 -0
- package/types/commands/CloseCommand.d.ts +25 -0
- package/types/commands/Command.d.ts +28 -0
- package/types/commands/DepsCommand.d.ts +32 -0
- package/types/commands/DepsMessage.d.ts +28 -0
- package/types/commands/HostCommand.d.ts +7 -7
- package/types/commands/HostMessage.d.ts +44 -0
- package/types/commands/InitCommand.d.ts +24 -19
- package/types/commands/InitMessage.d.ts +24 -0
- package/types/commands/ListCommand.d.ts +8 -8
- package/types/commands/ListMessage.d.ts +30 -0
- package/types/commands/PublishCommand.d.ts +36 -47
- package/types/commands/PublishMessage.d.ts +39 -0
- package/types/commands/SealCommand.d.ts +7 -7
- package/types/commands/SealMessage.d.ts +28 -0
- package/types/commands/ServeCommand.d.ts +7 -7
- package/types/commands/ServeMessage.d.ts +30 -0
- package/types/commands/ShowCommand.d.ts +7 -7
- package/types/commands/SpecCommand.d.ts +25 -0
- package/types/commands/StatusCommand.d.ts +9 -0
- package/types/commands/SubCommand.d.ts +9 -7
- package/types/commands/ValidateCommand.d.ts +7 -7
- package/types/commands/ValidateMessage.d.ts +20 -0
- package/types/db/ReleaseDB.d.ts +2 -2
- package/types/index.d.ts +10 -0
- package/types/ui/cli/ReleaseCLi.d.ts +10 -0
- package/types/ui/cli/index.d.ts +0 -0
- package/types/utils/runSpawn.d.ts +0 -0
- package/.datasets/README.dataset.jsonl +0 -19
- package/.editorconfig +0 -20
- package/CHANGELOG.md +0 -6
- package/CONTRIBUTING.md +0 -42
- package/bin/commands/InitCommand.js +0 -10
- package/bin/lib/functions.js +0 -240
- package/bin/lib/functions.test.js +0 -138
- package/bin/release.js +0 -12
- package/bin/release.test.js +0 -73
- package/bin/temp/package.json +0 -1
- package/docs/system.uk.md +0 -413
- package/docs/uk/README.md +0 -284
- package/legacy/PrepareCommand.js +0 -154
- package/legacy/PrepareCommand.test.js +0 -189
- package/legacy/changelog.js +0 -446
- package/releases/1/0/v1.0.0/models/Person.js +0 -26
- package/releases/1/0/v1.0.0/models/Person.test.js +0 -44
- package/releases/1/0/v1.0.0/models/company.js +0 -11
- package/releases/1/0/v1.0.0/models/members.js +0 -14
- package/releases/1/0/v1.0.0/models/members.test.js +0 -21
- package/releases/1/0/v1.0.0/models/teams/DevTeam.js +0 -6
- package/releases/1/0/v1.0.0/models/teams/DevTeam.test.js +0 -15
- package/releases/1/0/v1.0.0/models/teams/index.js +0 -5
- package/releases/1/0/v1.0.0/release.js +0 -12
- package/releases/1/0/v1.0.0/release.md +0 -121
- package/releases/1/0/v1.0.0/release.test.js +0 -36
- package/releases/1/0/v1.0.0/test/YaRaSLove/git-native.test.js +0 -14
- package/releases/current.js +0 -3
- package/releases/index.js +0 -11
- package/src/Release/MarkdownToTest.test.js +0 -60
- package/src/ReleaseCLI.js +0 -122
- package/src/architecture/ProjectManagementAsCode.test.js +0 -128
- package/src/co/AppCommandMessage.js +0 -22
- package/src/commands/ChatCommand.js +0 -56
- package/src/commands/HostCommand.js +0 -63
- package/src/commands/ListCommand.js +0 -56
- package/src/commands/SealCommand.js +0 -51
- package/src/commands/ServeCommand.js +0 -53
- package/src/commands/ShowCommand.js +0 -58
- package/src/commands/SubCommand.js +0 -21
- package/src/commands/ValidateCommand.js +0 -66
- package/system.md +0 -571
- package/tsconfig.json +0 -23
- /package/{bin/lib/temp/pnpm-lock.yaml → src/ui/cli/index.js} +0 -0
package/bin/lib/functions.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs'
|
|
2
|
-
import { execSync } from 'node:child_process'
|
|
3
|
-
import Logger from '@nan0web/log'
|
|
4
|
-
|
|
5
|
-
export const GREEN = '\x1b[32m'
|
|
6
|
-
export const RESET = '\x1b[0m'
|
|
7
|
-
export const OK = '✓'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Detect package manager used in the project
|
|
11
|
-
* @returns {string} - Detected package manager (npm, yarn, pnpm)
|
|
12
|
-
*/
|
|
13
|
-
export function detectPackageManager() {
|
|
14
|
-
if (existsSync('pnpm-lock.yaml')) return 'pnpm'
|
|
15
|
-
if (existsSync('yarn.lock')) return 'yarn'
|
|
16
|
-
if (existsSync('package-lock.json')) return 'npm'
|
|
17
|
-
|
|
18
|
-
// Default to npm if no lock file is found
|
|
19
|
-
return 'npm'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Get package manager specific commands
|
|
24
|
-
* @param {string} packageManager - Package manager name
|
|
25
|
-
* @returns {object} - Commands map
|
|
26
|
-
*/
|
|
27
|
-
export function getPackageManagerCommands(packageManager) {
|
|
28
|
-
const commands = {
|
|
29
|
-
pnpm: {
|
|
30
|
-
cacheClean: 'pnpm store prune',
|
|
31
|
-
install: 'pnpm install',
|
|
32
|
-
update: 'pnpm update --latest',
|
|
33
|
-
prune: 'pnpm prune',
|
|
34
|
-
outdated: 'pnpm outdated',
|
|
35
|
-
lint: 'pnpm run lint',
|
|
36
|
-
test: 'pnpm run test',
|
|
37
|
-
build: 'pnpm run build',
|
|
38
|
-
clean: 'pnpm run clean',
|
|
39
|
-
publish: 'pnpm publish --access public',
|
|
40
|
-
pushTags: "git push origin --tags",
|
|
41
|
-
push: 'git push',
|
|
42
|
-
list: 'pnpm list',
|
|
43
|
-
storeStatus: 'pnpm store status'
|
|
44
|
-
},
|
|
45
|
-
yarn: {
|
|
46
|
-
cacheClean: 'yarn cache clean',
|
|
47
|
-
install: 'yarn install',
|
|
48
|
-
update: 'yarn upgrade',
|
|
49
|
-
prune: 'yarn autoclean --force',
|
|
50
|
-
outdated: 'yarn outdated',
|
|
51
|
-
lint: 'yarn run lint',
|
|
52
|
-
test: 'yarn run test',
|
|
53
|
-
build: 'yarn run build',
|
|
54
|
-
clean: 'yarn run clean',
|
|
55
|
-
publish: 'yarn publish --access public',
|
|
56
|
-
pushTags: 'git push origin --tags',
|
|
57
|
-
push: 'git push',
|
|
58
|
-
list: 'yarn list',
|
|
59
|
-
storeStatus: null
|
|
60
|
-
},
|
|
61
|
-
npm: {
|
|
62
|
-
cacheClean: 'npm cache clean --force',
|
|
63
|
-
installF: 'npm install',
|
|
64
|
-
update: 'npm update',
|
|
65
|
-
prune: 'npm prune',
|
|
66
|
-
outdated: 'npm outdated',
|
|
67
|
-
lint: 'npm run lint',
|
|
68
|
-
test: 'npm test',
|
|
69
|
-
build: 'npm run build',
|
|
70
|
-
clean: 'npm run clean',
|
|
71
|
-
publish: 'npm publish --access public',
|
|
72
|
-
pushTags: 'git push origin --tags',
|
|
73
|
-
push: 'git push',
|
|
74
|
-
list: 'npm list',
|
|
75
|
-
storeStatus: null
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return commands[packageManager] || commands.npm
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Run shell command
|
|
83
|
-
* @param {string} command - Command to execute
|
|
84
|
-
* @param {string} errorMessage - Error message to show if command fails
|
|
85
|
-
*/
|
|
86
|
-
export function runCommand(command, errorMessage) {
|
|
87
|
-
const logger = new Logger({ level: 'info' })
|
|
88
|
-
try {
|
|
89
|
-
logger.debug(`Executing command: ${command}`)
|
|
90
|
-
execSync(command, { stdio: 'inherit' })
|
|
91
|
-
} catch (err) {
|
|
92
|
-
logger.error(errorMessage)
|
|
93
|
-
logger.debug(err.stack)
|
|
94
|
-
process.exit(1)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Check if package.json has required scripts and dependencies
|
|
100
|
-
* @param {string} packageJsonPath - Path to package.json
|
|
101
|
-
* @param {boolean} fix - Whether to attempt fixing issues
|
|
102
|
-
* @returns {number} - Exit code (0 for success)
|
|
103
|
-
*/
|
|
104
|
-
export function checkPackageJson(packageJsonPath, fix = false) {
|
|
105
|
-
const logger = new Logger({ level: 'info' })
|
|
106
|
-
try {
|
|
107
|
-
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
|
|
108
|
-
const requiredScripts = ['dev', 'build', 'preview', 'test', 'clean']
|
|
109
|
-
const missingScripts = requiredScripts.filter(script => !pkg.scripts?.[script])
|
|
110
|
-
|
|
111
|
-
if (missingScripts.length > 0) {
|
|
112
|
-
logger.warn(`Missing scripts in package.json: ${missingScripts.join(', ')}`)
|
|
113
|
-
if (fix) {
|
|
114
|
-
// Add missing scripts with default commands
|
|
115
|
-
pkg.scripts = pkg.scripts || {}
|
|
116
|
-
missingScripts.forEach(script => {
|
|
117
|
-
switch (script) {
|
|
118
|
-
case 'dev': pkg.scripts.dev = 'vite'; break
|
|
119
|
-
case 'build': pkg.scripts.build = 'vite build'; break
|
|
120
|
-
case 'preview': pkg.scripts.preview = 'vite preview'; break
|
|
121
|
-
case 'test': pkg.scripts.test = 'vitest'; break
|
|
122
|
-
case 'clean': pkg.scripts.clean = 'rm -rf dist'; break
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2))
|
|
126
|
-
logger.info(`Fixed missing scripts in package.json`)
|
|
127
|
-
} else {
|
|
128
|
-
return 1
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Check for husky dependency
|
|
133
|
-
if (!pkg.devDependencies?.husky) {
|
|
134
|
-
logger.warn('Missing husky in devDependencies')
|
|
135
|
-
if (fix) {
|
|
136
|
-
pkg.devDependencies = pkg.devDependencies || {}
|
|
137
|
-
pkg.devDependencies.husky = '^8.0.0'
|
|
138
|
-
writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2))
|
|
139
|
-
logger.info('Added husky to devDependencies')
|
|
140
|
-
} else {
|
|
141
|
-
return 1
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
} catch (err) {
|
|
145
|
-
logger.error(`Failed to check package.json: ${err.message}`)
|
|
146
|
-
logger.debug(err.stack)
|
|
147
|
-
return 1
|
|
148
|
-
}
|
|
149
|
-
return 0
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Check pre-commit hooks
|
|
154
|
-
* @param {string} packageJsonPath - Path to package.json
|
|
155
|
-
* @param {boolean} fix - Whether to attempt fixing issues
|
|
156
|
-
* @returns {number} - Exit code (0 for success)
|
|
157
|
-
*/
|
|
158
|
-
export function checkPreCommits(packageJsonPath, fix = false) {
|
|
159
|
-
const logger = new Logger({ level: 'info' })
|
|
160
|
-
try {
|
|
161
|
-
const huskyDir = resolve(dirname(packageJsonPath), '.husky')
|
|
162
|
-
const preCommitFile = resolve(huskyDir, 'pre-commit')
|
|
163
|
-
|
|
164
|
-
if (!existsSync(preCommitFile)) {
|
|
165
|
-
logger.warn('Missing pre-commit hook file')
|
|
166
|
-
if (fix) {
|
|
167
|
-
if (!existsSync(huskyDir)) {
|
|
168
|
-
mkdirSync(huskyDir)
|
|
169
|
-
}
|
|
170
|
-
writeFileSync(preCommitFile, '#!/bin/sh\n. "$(dirname "$0")/_/husky.sh"\n\npnpm run test\n')
|
|
171
|
-
execSync('chmod +x ' + preCommitFile)
|
|
172
|
-
logger.info('Created pre-commit hook file')
|
|
173
|
-
} else {
|
|
174
|
-
return 1
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
} catch (err) {
|
|
178
|
-
logger.error(`Failed to check pre-commit hooks: ${err.message}`)
|
|
179
|
-
logger.debug(err.stack)
|
|
180
|
-
return 1
|
|
181
|
-
}
|
|
182
|
-
return 0
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Check for uncommitted changes
|
|
187
|
-
* @param {object} params - Parameters
|
|
188
|
-
* @param {string} params.version - Current version
|
|
189
|
-
* @param {object} params.devDependencies - Development dependencies
|
|
190
|
-
* @param {object} params.dependencies - Production dependencies
|
|
191
|
-
*/
|
|
192
|
-
export function checkUncommitted({ version, devDependencies, dependencies }) {
|
|
193
|
-
const logger = new Logger({ level: 'info' })
|
|
194
|
-
try {
|
|
195
|
-
execSync('git diff-index --quiet HEAD --', { stdio: 'ignore' })
|
|
196
|
-
execSync('git diff-files --quiet', { stdio: 'ignore' })
|
|
197
|
-
} catch (err) {
|
|
198
|
-
logger.error(`There are uncommitted changes in your repository at version ${version}`)
|
|
199
|
-
logger.debug('Dependencies:', dependencies)
|
|
200
|
-
logger.debug('Dev Dependencies:', devDependencies)
|
|
201
|
-
logger.debug(err.stack)
|
|
202
|
-
process.exit(1)
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Check if git tag exists
|
|
208
|
-
* @param {string} tag - Tag to check
|
|
209
|
-
* @returns {boolean} - Whether tag exists
|
|
210
|
-
*/
|
|
211
|
-
export function tagExists(tag) {
|
|
212
|
-
try {
|
|
213
|
-
execSync(`git rev-parse ${tag}`, { stdio: 'ignore' })
|
|
214
|
-
return true
|
|
215
|
-
} catch {
|
|
216
|
-
return false
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Tag release in git
|
|
222
|
-
* @param {string} version - Version to tag
|
|
223
|
-
*/
|
|
224
|
-
export function tagRelease(version) {
|
|
225
|
-
const tag = `v${version}`
|
|
226
|
-
const logger = new Logger({ level: 'info' })
|
|
227
|
-
|
|
228
|
-
if (tagExists(tag)) {
|
|
229
|
-
logger.warn(`Tag ${tag} already exists`)
|
|
230
|
-
return
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
try {
|
|
234
|
-
execSync(`git tag -a ${tag} -m "Release version ${version}"`, { stdio: 'inherit' })
|
|
235
|
-
} catch (err) {
|
|
236
|
-
logger.error(`Failed to tag release ${tag}`)
|
|
237
|
-
logger.debug(err.stack)
|
|
238
|
-
process.exit(1)
|
|
239
|
-
}
|
|
240
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test'
|
|
2
|
-
import assert from 'node:assert'
|
|
3
|
-
import { existsSync, writeFileSync, unlinkSync, mkdirSync, readFileSync } from 'node:fs'
|
|
4
|
-
import { resolve, dirname } from 'node:path'
|
|
5
|
-
import { fileURLToPath } from 'node:url'
|
|
6
|
-
import { spawnSync } from 'node:child_process'
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
getPackageManagerCommands,
|
|
10
|
-
checkPackageJson,
|
|
11
|
-
checkPreCommits,
|
|
12
|
-
runCommand,
|
|
13
|
-
checkUncommitted,
|
|
14
|
-
tagExists,
|
|
15
|
-
tagRelease,
|
|
16
|
-
detectPackageManager,
|
|
17
|
-
} from './functions.js'
|
|
18
|
-
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
20
|
-
const __dirname = dirname(__filename)
|
|
21
|
-
const tempDir = resolve(__dirname, 'temp')
|
|
22
|
-
const tempPackageJson = resolve(tempDir, 'package.json')
|
|
23
|
-
|
|
24
|
-
describe('functions.js', () => {
|
|
25
|
-
// Setup temporary directory and package.json for testing
|
|
26
|
-
if (!existsSync(tempDir)) mkdirSync(tempDir)
|
|
27
|
-
writeFileSync(tempPackageJson, JSON.stringify({ name: 'test-package' }))
|
|
28
|
-
|
|
29
|
-
it('detectPackageManager returns correct package manager', () => {
|
|
30
|
-
// Create temporary lock files to simulate package managers
|
|
31
|
-
const pnpmLock = resolve(tempDir, 'pnpm-lock.yaml')
|
|
32
|
-
const yarnLock = resolve(tempDir, 'yarn.lock')
|
|
33
|
-
|
|
34
|
-
writeFileSync(pnpmLock, '')
|
|
35
|
-
assert.strictEqual(detectPackageManager(), 'pnpm')
|
|
36
|
-
unlinkSync(pnpmLock)
|
|
37
|
-
|
|
38
|
-
writeFileSync(yarnLock, '')
|
|
39
|
-
assert.strictEqual(detectPackageManager(), 'yarn')
|
|
40
|
-
unlinkSync(yarnLock)
|
|
41
|
-
|
|
42
|
-
// Default case (npm)
|
|
43
|
-
assert.strictEqual(detectPackageManager(), 'npm')
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('getPackageManagerCommands returns correct commands', () => {
|
|
47
|
-
const pnpmCommands = getPackageManagerCommands('pnpm')
|
|
48
|
-
assert.ok(pnpmCommands.cacheClean)
|
|
49
|
-
assert.ok(pnpmCommands.install)
|
|
50
|
-
assert.ok(pnpmCommands.update)
|
|
51
|
-
assert.ok(pnpmCommands.prune)
|
|
52
|
-
assert.ok(pnpmCommands.outdated)
|
|
53
|
-
assert.ok(pnpmCommands.build)
|
|
54
|
-
assert.ok(pnpmCommands.lint)
|
|
55
|
-
assert.ok(pnpmCommands.test)
|
|
56
|
-
assert.ok(pnpmCommands.list)
|
|
57
|
-
assert.ok(pnpmCommands.storeStatus)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('checkPackageJson validates required scripts and dependencies', () => {
|
|
61
|
-
const result = checkPackageJson(tempPackageJson, true)
|
|
62
|
-
assert.strictEqual(result, 0)
|
|
63
|
-
|
|
64
|
-
const pkg = JSON.parse(readFileSync(tempPackageJson, 'utf8'))
|
|
65
|
-
assert.ok(pkg.scripts.dev)
|
|
66
|
-
assert.ok(pkg.scripts.build)
|
|
67
|
-
assert.ok(pkg.scripts.preview)
|
|
68
|
-
assert.ok(pkg.scripts.test)
|
|
69
|
-
assert.ok(pkg.scripts.clean)
|
|
70
|
-
assert.ok(pkg.devDependencies.husky)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
it('checkPreCommits handles missing pre-commit file', () => {
|
|
74
|
-
const result = checkPreCommits(tempPackageJson, true)
|
|
75
|
-
assert.strictEqual(result, 0)
|
|
76
|
-
|
|
77
|
-
const huskyDir = resolve(tempDir, '.husky')
|
|
78
|
-
const preCommitFile = resolve(huskyDir, 'pre-commit')
|
|
79
|
-
assert.ok(existsSync(preCommitFile))
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('runCommand executes shell commands', () => {
|
|
83
|
-
// This test will pass if the command runs successfully
|
|
84
|
-
assert.doesNotThrow(() => {
|
|
85
|
-
runCommand('echo "test"', 'Failed to echo')
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('checkUncommitted validates git status', () => {
|
|
90
|
-
// This test assumes no uncommitted changes in the test environment
|
|
91
|
-
assert.doesNotThrow(() => {
|
|
92
|
-
checkUncommitted({ devDependencies: {}, dependencies: {} })
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('tagExists checks for existing git tags', () => {
|
|
97
|
-
// Assuming no tags exist initially
|
|
98
|
-
assert.strictEqual(tagExists('v0.0.0'), false)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('tagRelease creates and pushes git tags', () => {
|
|
102
|
-
// Mock version for testing
|
|
103
|
-
const version = '0.0.1-test'
|
|
104
|
-
const tag = `v${version}`
|
|
105
|
-
|
|
106
|
-
// Create tag
|
|
107
|
-
spawnSync('git', ['tag', '-a', tag, '-m', `Release version ${version}`], { cwd: tempDir })
|
|
108
|
-
|
|
109
|
-
// Test tag exists
|
|
110
|
-
assert.strictEqual(tagExists(tag), true)
|
|
111
|
-
|
|
112
|
-
// Clean up tag
|
|
113
|
-
spawnSync('git', ['tag', '-d', tag], { cwd: tempDir })
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('tagRelease handles existing tags', () => {
|
|
117
|
-
const version = '0.0.2-test'
|
|
118
|
-
const tag = `v${version}`
|
|
119
|
-
|
|
120
|
-
// Create tag first
|
|
121
|
-
spawnSync('git', ['tag', '-a', tag, '-m', `Release version ${version}`], { cwd: tempDir })
|
|
122
|
-
|
|
123
|
-
// Should not create tag again
|
|
124
|
-
const logger = new Logger({ level: 'info' })
|
|
125
|
-
const originalLog = logger.warn
|
|
126
|
-
let warnCalled = false
|
|
127
|
-
logger.warn = () => { warnCalled = true }
|
|
128
|
-
|
|
129
|
-
tagRelease(version)
|
|
130
|
-
assert.ok(warnCalled)
|
|
131
|
-
|
|
132
|
-
// Clean up tag
|
|
133
|
-
spawnSync('git', ['tag', '-d', tag], { cwd: tempDir })
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
// Cleanup
|
|
137
|
-
unlinkSync(tempPackageJson)
|
|
138
|
-
})
|
package/bin/release.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import ReleaseCLI from '../src/ReleaseCLI.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Entry point for the release CLI application
|
|
7
|
-
*/
|
|
8
|
-
const cli = new ReleaseCLI()
|
|
9
|
-
cli.run(process.argv.slice(2)).catch(error => {
|
|
10
|
-
console.error(error)
|
|
11
|
-
process.exit(1)
|
|
12
|
-
})
|
package/bin/release.test.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import FS from "@nan0web/db-fs"
|
|
4
|
-
import { existsSync, writeFileSync, unlinkSync, mkdirSync, readFileSync } from 'node:fs'
|
|
5
|
-
import { resolve, dirname } from 'node:path'
|
|
6
|
-
import { fileURLToPath } from 'node:url'
|
|
7
|
-
|
|
8
|
-
import main from './release.js'
|
|
9
|
-
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
11
|
-
const __dirname = dirname(__filename)
|
|
12
|
-
const tempDir = resolve(__dirname, 'temp')
|
|
13
|
-
const tempPackageJson = resolve(tempDir, 'package.json')
|
|
14
|
-
|
|
15
|
-
const fs = new FS()
|
|
16
|
-
|
|
17
|
-
describe('release.js', async () => {
|
|
18
|
-
await fs.connect()
|
|
19
|
-
const tempDir = "tmp/release"
|
|
20
|
-
const db = fs.extract(tempDir)
|
|
21
|
-
await db.writeDocument("package.json", {
|
|
22
|
-
name: 'test-package',
|
|
23
|
-
version: '0.0.1-test'
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
// Mock process.cwd to return tempDir
|
|
27
|
-
const originalCwd = process.cwd
|
|
28
|
-
process.cwd = () => tempDir
|
|
29
|
-
|
|
30
|
-
it('main function processes release command', async () => {
|
|
31
|
-
// Test with ignore flags to avoid actual git operations
|
|
32
|
-
const result = await main(['--ignore-uncommitted', '--ignore-fail-tests', '--ignore-tag'])
|
|
33
|
-
assert.ok(result.includes('Release completed'))
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('main function processes prepare command', async () => {
|
|
37
|
-
const resultP= await main(['prepare'])
|
|
38
|
-
assert.ok(result.includes('Prepare completed'))
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('ReleaseCommand handles package.json validation', async () => {
|
|
42
|
-
// Create a package.json without required scripts
|
|
43
|
-
writeFileSync(tempPackageJson, JSON.stringify({
|
|
44
|
-
name: 'test-package',
|
|
45
|
-
version: '0.0.1-test'
|
|
46
|
-
}))
|
|
47
|
-
|
|
48
|
-
// Should exit with error when missing scripts
|
|
49
|
-
try {
|
|
50
|
-
await main(['--ignore-uncommitted', '--ignore-fail-tests', '--ignore-tag'])
|
|
51
|
-
assert.fail('Should have exited with error')
|
|
52
|
-
} catch (err) {
|
|
53
|
-
assert.ok(err.message.includes('Missing required scripts'))
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Should fix when --fix flag is used
|
|
57
|
-
const result = await main(['--ignore-uncommitted', '--ignore-fail-tests', '--ignore-tag', '--fix'])
|
|
58
|
-
assert.ok(result.includes('Release completed'))
|
|
59
|
-
|
|
60
|
-
// Verify package.json was fixed
|
|
61
|
-
const pkg = JSON.parse(readFileSync(tempPackageJson, 'utf8'))
|
|
62
|
-
assert.ok(pkg.scripts.dev)
|
|
63
|
-
assert.ok(pkg.scripts.build)
|
|
64
|
-
assert.ok(pkg.scripts.preview)
|
|
65
|
-
assert.ok(pkg.scripts.test)
|
|
66
|
-
assert.ok(pkg.scripts.clean)
|
|
67
|
-
assert.ok(pkg.devDependencies.husky)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
// Cleanup
|
|
71
|
-
process.cwd = originalCwd
|
|
72
|
-
await db.dropDocument("package.json")
|
|
73
|
-
})
|
package/bin/temp/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"test-package","version":"0.0.1-test"}
|