create-node-lib 2.9.3 → 2.9.4
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/CHANGELOG.md +7 -0
- package/__tests__/generator.test.js +62 -0
- package/package.json +1 -1
- package/saofile.js +7 -0
- package/template/.changeset/config.json +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.9.4](https://github.com/lirantal/create-node-lib/compare/v2.9.3...v2.9.4) (2026-01-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add default changeset configuration to scaffolded projects ([#41](https://github.com/lirantal/create-node-lib/issues/41)) ([2cc16c6](https://github.com/lirantal/create-node-lib/commit/2cc16c6d05dc4921ac7247639771b2b1bf3c63e4))
|
|
7
|
+
|
|
1
8
|
## [2.9.3](https://github.com/lirantal/create-node-lib/compare/v2.9.2...v2.9.3) (2026-01-23)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -94,4 +94,66 @@ describe('all the template files are accountable for', () => {
|
|
|
94
94
|
const pkg = JSON.parse(await stream.readFile('package.json'))
|
|
95
95
|
expect(pkg.scripts.prepare).toBe('husky')
|
|
96
96
|
})
|
|
97
|
+
|
|
98
|
+
test('Generator creates changeset config.json file', async () => {
|
|
99
|
+
const stream = await sao.mock({ generator: template })
|
|
100
|
+
expect(stream.fileList).toContain('.changeset/config.json')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test('Generator creates changeset config with correct repo from projectRepository', async () => {
|
|
104
|
+
const mockProjectRepository = 'https://github.com/alice/wonderland'
|
|
105
|
+
|
|
106
|
+
const stream = await sao.mock(
|
|
107
|
+
{ generator: template },
|
|
108
|
+
{
|
|
109
|
+
projectRepository: mockProjectRepository
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
const changesetConfig = JSON.parse(await stream.readFile('.changeset/config.json'))
|
|
114
|
+
expect(changesetConfig.changelog[1].repo).toBe('alice/wonderland')
|
|
115
|
+
expect(changesetConfig.$schema).toBe('https://unpkg.com/@changesets/config/schema.json')
|
|
116
|
+
expect(changesetConfig.access).toBe('public')
|
|
117
|
+
expect(changesetConfig.baseBranch).toBe('main')
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('Generator creates changeset config with repo extracted from .git URL', async () => {
|
|
121
|
+
const mockProjectRepository = 'https://github.com/bob/project.git'
|
|
122
|
+
|
|
123
|
+
const stream = await sao.mock(
|
|
124
|
+
{ generator: template },
|
|
125
|
+
{
|
|
126
|
+
projectRepository: mockProjectRepository
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
const changesetConfig = JSON.parse(await stream.readFile('.changeset/config.json'))
|
|
131
|
+
expect(changesetConfig.changelog[1].repo).toBe('bob/project')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
test('Generator handles URL with trailing slash', async () => {
|
|
135
|
+
const mockProjectRepository = 'https://github.com/user/repo/'
|
|
136
|
+
|
|
137
|
+
const stream = await sao.mock(
|
|
138
|
+
{ generator: template },
|
|
139
|
+
{
|
|
140
|
+
projectRepository: mockProjectRepository
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
const changesetConfig = JSON.parse(await stream.readFile('.changeset/config.json'))
|
|
145
|
+
expect(changesetConfig.changelog[1].repo).toBe('user/repo')
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
test('Generator handles empty projectRepository gracefully', async () => {
|
|
149
|
+
const stream = await sao.mock(
|
|
150
|
+
{ generator: template },
|
|
151
|
+
{
|
|
152
|
+
projectRepository: ''
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
const changesetConfig = JSON.parse(await stream.readFile('.changeset/config.json'))
|
|
157
|
+
expect(changesetConfig.changelog[1].repo).toBe('')
|
|
158
|
+
})
|
|
97
159
|
})
|
package/package.json
CHANGED
package/saofile.js
CHANGED
|
@@ -9,6 +9,13 @@ module.exports = {
|
|
|
9
9
|
year: new Date().getFullYear(),
|
|
10
10
|
npmClientInstall: ({ npmClient }) => {
|
|
11
11
|
return npmClient === 'npm' ? 'install' : 'add'
|
|
12
|
+
},
|
|
13
|
+
changesetRepo: ({ projectRepository }) => {
|
|
14
|
+
// Extract owner/repo from URL like https://github.com/username/reponame
|
|
15
|
+
// or https://github.com/username/reponame.git
|
|
16
|
+
if (!projectRepository || typeof projectRepository !== 'string') return ''
|
|
17
|
+
const match = projectRepository.match(/github\.com\/([^/]+\/[^/.?#]+)/)
|
|
18
|
+
return match ? match[1] : ''
|
|
12
19
|
}
|
|
13
20
|
},
|
|
14
21
|
prompts() {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config/schema.json",
|
|
3
|
+
"changelog": [
|
|
4
|
+
"@changesets/changelog-github",
|
|
5
|
+
{
|
|
6
|
+
"repo": "<%- changesetRepo({ projectRepository }) %>"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"commit": false,
|
|
10
|
+
"fixed": [],
|
|
11
|
+
"linked": [],
|
|
12
|
+
"access": "public",
|
|
13
|
+
"baseBranch": "main",
|
|
14
|
+
"updateInternalDependencies": "patch",
|
|
15
|
+
"ignore": []
|
|
16
|
+
}
|