@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/legacy/PrepareCommand.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process'
|
|
2
|
-
import DB from '@nan0web/db-fs'
|
|
3
|
-
import Logger from '@nan0web/log'
|
|
4
|
-
import { Changelog } from '@nan0web/changelog'
|
|
5
|
-
import { Command } from '@nan0web/co'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} PrepareCommandOpts
|
|
9
|
-
* @property {boolean} laconic
|
|
10
|
-
* @property {boolean} descriptive
|
|
11
|
-
* @property {string} template
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Prepare command class
|
|
15
|
-
*/
|
|
16
|
-
class PrepareCommand extends Command {
|
|
17
|
-
/** @type {Logger} */
|
|
18
|
-
logger
|
|
19
|
-
/** @type {PrepareCommandOpts} */
|
|
20
|
-
opts
|
|
21
|
-
/** @type {string} */
|
|
22
|
-
cwd
|
|
23
|
-
/** @type {DB} */
|
|
24
|
-
db
|
|
25
|
-
|
|
26
|
-
constructor(options = {}) {
|
|
27
|
-
const {
|
|
28
|
-
logger = new Logger(),
|
|
29
|
-
cwd = ".",
|
|
30
|
-
} = options
|
|
31
|
-
super(options)
|
|
32
|
-
this.logger = Logger.from(logger)
|
|
33
|
-
this.cwd = String(cwd)
|
|
34
|
-
this.options = new Map([
|
|
35
|
-
["laconic", [false, "Generate laconic changelog"]],
|
|
36
|
-
["descriptive", [false, "Generate descriptive changelog"]],
|
|
37
|
-
["template", [String, "Template file or message for a changelog"]],
|
|
38
|
-
])
|
|
39
|
-
this.db = new DB({ cwd: this.cwd })
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Run the prepare command
|
|
44
|
-
* @param {string[]} args - Command arguments
|
|
45
|
-
* @returns {Promise<void>}
|
|
46
|
-
*/
|
|
47
|
-
async run(args) {
|
|
48
|
-
let content = await this.db.loadDocument('CHANGELOG.md', '')
|
|
49
|
-
|
|
50
|
-
const changelog = new Changelog()
|
|
51
|
-
changelog.parse(content)
|
|
52
|
-
changelog.init()
|
|
53
|
-
const latest = changelog.getLatestVersion()
|
|
54
|
-
const versions = changelog.getVersions()
|
|
55
|
-
|
|
56
|
-
// Get git changes
|
|
57
|
-
const changes = this.getGitChanges()
|
|
58
|
-
|
|
59
|
-
if (changes.length > 0) {
|
|
60
|
-
const promptContent = await this.generateChangelogPrompt(changes)
|
|
61
|
-
await this.db.writeDocument("me.md", String(promptContent))
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Save updated changelog
|
|
65
|
-
await this.db.saveDocument('CHANGELOG.md', String(changelog.document))
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get list of new and modified files from git
|
|
70
|
-
* @returns {string[]} - Array of file paths
|
|
71
|
-
*/
|
|
72
|
-
getGitChanges() {
|
|
73
|
-
try {
|
|
74
|
-
// Get uncommitted changes
|
|
75
|
-
const statusOutput = execSync('git status --porcelain', {
|
|
76
|
-
cwd: this.cwd,
|
|
77
|
-
encoding: 'utf8'
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const changes = statusOutput
|
|
81
|
-
.split('\n')
|
|
82
|
-
.filter(line => line.trim() !== '')
|
|
83
|
-
.map(line => {
|
|
84
|
-
const parts = line.trim().split(/\s+/)
|
|
85
|
-
return parts[1]
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
return changes
|
|
89
|
-
} catch (e) {
|
|
90
|
-
this.logger.warn('Git repository not found or git command failed')
|
|
91
|
-
return []
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Generate changelog prompt from file changes
|
|
97
|
-
* @param {string[]} changes - Array of changed file paths
|
|
98
|
-
* @returns {Promise<string>} - Prompt content
|
|
99
|
-
*/
|
|
100
|
-
async generateChangelogPrompt(changes) {
|
|
101
|
-
const fileStats = []
|
|
102
|
-
for (const filePath of changes) {
|
|
103
|
-
try {
|
|
104
|
-
const stat = await this.db.statDocument(filePath)
|
|
105
|
-
fileStats.push({ path: filePath, isFile: stat.isFile })
|
|
106
|
-
} catch {
|
|
107
|
-
fileStats.push({ path: filePath, isFile: false })
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const files = fileStats
|
|
112
|
-
.filter(item => item.isFile)
|
|
113
|
-
.map(item => item.path)
|
|
114
|
-
|
|
115
|
-
if (files.length === 0) {
|
|
116
|
-
return ''
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const promptLines = [
|
|
120
|
-
"Based on the following changed files, please provide changelog entries:",
|
|
121
|
-
]
|
|
122
|
-
|
|
123
|
-
const diffOutput = execSync('git diff --no-color HEAD', {
|
|
124
|
-
cwd: this.cwd,
|
|
125
|
-
encoding: 'utf8'
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
if (diffOutput.trim() !== '') {
|
|
129
|
-
promptLines.push('\n```diff\n' + diffOutput.trim() + '\n```')
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const newFiles = execSync('git ls-files --others --exclude-standard', {
|
|
133
|
-
cwd: this.cwd,
|
|
134
|
-
encoding: 'utf8'
|
|
135
|
-
}).split('\n').filter(line => line.trim() !== '')
|
|
136
|
-
|
|
137
|
-
for (const file of newFiles) {
|
|
138
|
-
try {
|
|
139
|
-
const content = await this.db.loadDocumentAs(".txt", file)
|
|
140
|
-
promptLines.push(`\n#### \`${file}\``)
|
|
141
|
-
promptLines.push('```')
|
|
142
|
-
promptLines.push(content)
|
|
143
|
-
promptLines.push('```')
|
|
144
|
-
} catch {
|
|
145
|
-
// ignore files that can't be read
|
|
146
|
-
this.logger.warn("Could not read file", file)
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return promptLines.join('\n')
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export default PrepareCommand
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test'
|
|
2
|
-
import { strict as assert } from 'node:assert'
|
|
3
|
-
import { execSync } from 'node:child_process'
|
|
4
|
-
import { mkdirSync, writeFileSync, existsSync, rmSync } from 'node:fs'
|
|
5
|
-
import { resolve } from 'node:path'
|
|
6
|
-
import DB from '@nan0web/db-fs'
|
|
7
|
-
import Logger from '@nan0web/log'
|
|
8
|
-
import PrepareCommand from './PrepareCommand.js'
|
|
9
|
-
|
|
10
|
-
describe('PrepareCommand', () => {
|
|
11
|
-
it('should initialize CHANGELOG.md if it is empty', async () => {
|
|
12
|
-
const testDir = resolve('test_data/empty_changelog')
|
|
13
|
-
|
|
14
|
-
// Remove directory if exists
|
|
15
|
-
if (existsSync(testDir)) {
|
|
16
|
-
rmSync(testDir, { recursive: true })
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
mkdirSync(testDir, { recursive: true })
|
|
20
|
-
|
|
21
|
-
// Initialize git repo
|
|
22
|
-
try {
|
|
23
|
-
execSync('git init', { cwd: testDir })
|
|
24
|
-
execSync('git config user.name "Test User"', { cwd: testDir })
|
|
25
|
-
execSync('git config user.email "test@example.com"', { cwd: testDir })
|
|
26
|
-
} catch (e) {
|
|
27
|
-
assert.fail('Failed to initialize git repository: ' + e.message)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Create empty CHANGELOG.md
|
|
31
|
-
writeFileSync(resolve(testDir, 'CHANGELOG.md'), '')
|
|
32
|
-
|
|
33
|
-
// Add and commit
|
|
34
|
-
try {
|
|
35
|
-
execSync('git add CHANGELOG.md', { cwd: testDir })
|
|
36
|
-
execSync('git commit -m "Initial commit"', { cwd: testDir })
|
|
37
|
-
} catch (e) {
|
|
38
|
-
// Ignore if nothing to commit
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const command = new PrepareCommand({
|
|
42
|
-
cwd: testDir,
|
|
43
|
-
logger: new Logger({ silent: true })
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
await command.run([])
|
|
48
|
-
} catch (e) {
|
|
49
|
-
assert.fail('Command failed: ' + e.message)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const db = new DB({ cwd: testDir })
|
|
53
|
-
const changelogContent = await db.loadDocument('CHANGELOG.md', '')
|
|
54
|
-
assert.ok(changelogContent.includes('# Changelog'), 'CHANGELOG.md should be initialized with header')
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('should generate changelog prompt with new and modified files', async () => {
|
|
58
|
-
const testDir = resolve('test_data/changes')
|
|
59
|
-
|
|
60
|
-
// Remove directory if exists
|
|
61
|
-
if (existsSync(testDir)) {
|
|
62
|
-
rmSync(testDir, { recursive: true })
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
mkdirSync(testDir, { recursive: true })
|
|
66
|
-
|
|
67
|
-
// Initialize git repo
|
|
68
|
-
try {
|
|
69
|
-
execSync('git init', { cwd: testDir })
|
|
70
|
-
execSync('git config user.name "Test User"', { cwd: testDir })
|
|
71
|
-
execSync('git config user.email "test@example.com"', { cwd: testDir })
|
|
72
|
-
// Create initial commit
|
|
73
|
-
writeFileSync(resolve(testDir, 'initial.txt'), 'initial content')
|
|
74
|
-
execSync('git add initial.txt', { cwd: testDir })
|
|
75
|
-
execSync('git commit -m "Initial commit"', { cwd: testDir })
|
|
76
|
-
} catch (e) {
|
|
77
|
-
assert.fail('Failed to initialize git repository: ' + e.message)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Create initial files
|
|
81
|
-
writeFileSync(resolve(testDir, 'CHANGELOG.md'), '# Changelog\n')
|
|
82
|
-
writeFileSync(resolve(testDir, 'existing-file.txt'), 'existing content\n')
|
|
83
|
-
|
|
84
|
-
// Add and commit initial files
|
|
85
|
-
try {
|
|
86
|
-
execSync('git add CHANGELOG.md existing-file.txt', { cwd: testDir })
|
|
87
|
-
execSync('git commit -m "Add initial files"', { cwd: testDir })
|
|
88
|
-
} catch (e) {
|
|
89
|
-
// Ignore if nothing to commit
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Make changes
|
|
93
|
-
writeFileSync(resolve(testDir, 'new-file.txt'), 'new content\n')
|
|
94
|
-
writeFileSync(resolve(testDir, 'existing-file.txt'), 'existing content\nmodified content\n')
|
|
95
|
-
|
|
96
|
-
const command = new PrepareCommand({
|
|
97
|
-
cwd: testDir,
|
|
98
|
-
logger: new Logger({ silent: true })
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
await command.run([])
|
|
103
|
-
} catch (err) {
|
|
104
|
-
assert.fail('Command failed: ' + err.message)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Test passes if no exception is thrown
|
|
108
|
-
assert.ok(true)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it('should include recent changelog entries in the prompt', async () => {
|
|
112
|
-
const testDir = resolve('test_data/recent_entries')
|
|
113
|
-
|
|
114
|
-
// Remove directory if exists
|
|
115
|
-
if (existsSync(testDir)) {
|
|
116
|
-
rmSync(testDir, { recursive: true })
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
mkdirSync(testDir, { recursive: true })
|
|
120
|
-
|
|
121
|
-
// Initialize git repo
|
|
122
|
-
try {
|
|
123
|
-
execSync('git init', { cwd: testDir })
|
|
124
|
-
execSync('git config user.name "Test User"', { cwd: testDir })
|
|
125
|
-
execSync('git config user.email "test@example.com"', { cwd: testDir })
|
|
126
|
-
// Create initial commit
|
|
127
|
-
writeFileSync(resolve(testDir, 'initial.txt'), 'initial content')
|
|
128
|
-
execSync('git add initial.txt', { cwd: testDir })
|
|
129
|
-
execSync('git commit -m "Initial commit"', { cwd: testDir })
|
|
130
|
-
} catch (e) {
|
|
131
|
-
assert.fail('Failed to initialize git repository: ' + e.message)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Create directories
|
|
135
|
-
mkdirSync(resolve(testDir, 'src'), { recursive: true })
|
|
136
|
-
|
|
137
|
-
// Create CHANGELOG.md with existing releases
|
|
138
|
-
const changelogContent = `# Changelog
|
|
139
|
-
|
|
140
|
-
## [1.2.0] - 2024-01-03
|
|
141
|
-
### Added
|
|
142
|
-
- New feature Y
|
|
143
|
-
|
|
144
|
-
## [1.1.0] - 2024-01-02
|
|
145
|
-
### Changed
|
|
146
|
-
- Improved performance of module X
|
|
147
|
-
|
|
148
|
-
## [1.0.0] - 2024-01-01
|
|
149
|
-
### Added
|
|
150
|
-
- Initial release
|
|
151
|
-
- Core functionality implemented
|
|
152
|
-
`
|
|
153
|
-
writeFileSync(resolve(testDir, 'CHANGELOG.md'), changelogContent)
|
|
154
|
-
|
|
155
|
-
// Add and commit CHANGELOG.md
|
|
156
|
-
try {
|
|
157
|
-
execSync('git add CHANGELOG.md', { cwd: testDir })
|
|
158
|
-
execSync('git commit -m "Add changelog with entries"', { cwd: testDir })
|
|
159
|
-
} catch (e) {
|
|
160
|
-
// Ignore if nothing to commit
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Make changes
|
|
164
|
-
writeFileSync(resolve(testDir, 'src/new-feature.js'), 'console.log("new feature")\n')
|
|
165
|
-
|
|
166
|
-
const command = new PrepareCommand({
|
|
167
|
-
cwd: testDir,
|
|
168
|
-
logger: new Logger({ silent: true })
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
await command.run([])
|
|
173
|
-
} catch (err) {
|
|
174
|
-
assert.fail('Command failed: ' + err.message)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const db = new DB({ cwd: testDir })
|
|
178
|
-
const promptContent = await db.loadDocument('me.md', '')
|
|
179
|
-
|
|
180
|
-
// Check that recent entries are included in the prompt
|
|
181
|
-
assert.ok(promptContent.includes('## [1.2.0] - 2024-01-03'), 'Prompt should include most recent entry')
|
|
182
|
-
assert.ok(promptContent.includes('## [1.1.0] - 2024-01-02'), 'Prompt should include second recent entry')
|
|
183
|
-
assert.ok(promptContent.includes('## [1.0.0] - 2024-01-01'), 'Prompt should include third recent entry')
|
|
184
|
-
|
|
185
|
-
// Check that the prompt contains the instruction about using these entries as examples
|
|
186
|
-
assert.ok(promptContent.includes('Based on the following changed files, please provide changelog entries:'),
|
|
187
|
-
'Prompt should contain instructions for generating changelog entries')
|
|
188
|
-
})
|
|
189
|
-
})
|