@jpetit/toolkit 3.1.2 → 3.1.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/lib/versions.ts +3 -2
- package/package.json +1 -1
- package/toolkit/about.ts +6 -9
- package/toolkit/index.ts +5 -6
- package/toolkit/upgrade.ts +2 -2
- package/toolkit/upload.ts +1 -1
package/lib/versions.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { execSync } from 'child_process'
|
|
2
2
|
import { join } from 'path'
|
|
3
3
|
import semver from 'semver'
|
|
4
|
+
import { PackageJson } from 'zod-package-json'
|
|
4
5
|
import tui from './tui'
|
|
5
6
|
import { nothing, projectDir, readJson } from './utils'
|
|
6
7
|
|
|
7
|
-
const packageJson = await readJson(join(projectDir(), 'package.json'))
|
|
8
|
+
export const packageJson = PackageJson.parse(await readJson(join(projectDir(), 'package.json')))
|
|
8
9
|
|
|
9
10
|
export async function checkVersion(): Promise<void> {
|
|
10
11
|
const currentVersion = await getCurrentVersion()
|
|
@@ -20,7 +21,7 @@ export async function checkVersion(): Promise<void> {
|
|
|
20
21
|
|
|
21
22
|
export async function getCurrentVersion(): Promise<string> {
|
|
22
23
|
await nothing()
|
|
23
|
-
return packageJson.version
|
|
24
|
+
return packageJson.version
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export async function getLatestPublishedVersion(): Promise<string> {
|
package/package.json
CHANGED
package/toolkit/about.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Command } from '@commander-js/extra-typings'
|
|
2
2
|
import chalk from 'chalk'
|
|
3
|
-
import { nothing, projectDir, readJson } from '../lib/utils.ts'
|
|
4
|
-
import { join } from 'path'
|
|
5
|
-
import { PackageJson } from 'zod-package-json'
|
|
6
3
|
import tui from '../lib/tui.ts'
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { nothing } from '../lib/utils.ts'
|
|
5
|
+
import { packageJson } from '../lib/versions.ts'
|
|
9
6
|
|
|
10
7
|
export const aboutCmd = new Command('about')
|
|
11
8
|
.description('Get information about jutge-toolkit')
|
|
@@ -13,20 +10,20 @@ export const aboutCmd = new Command('about')
|
|
|
13
10
|
.action(async () => {
|
|
14
11
|
await nothing()
|
|
15
12
|
tui.print(chalk.bold(`jutge-toolkit ${packageJson.version}`))
|
|
16
|
-
tui.print(packageJson.description
|
|
13
|
+
tui.print(packageJson.description)
|
|
17
14
|
tui.print('')
|
|
18
15
|
tui.url(packageJson.homepage!)
|
|
19
16
|
tui.print('')
|
|
20
17
|
tui.print('Author:')
|
|
21
|
-
|
|
18
|
+
showPerson(packageJson.author!)
|
|
22
19
|
tui.print('')
|
|
23
20
|
tui.print('Contributors:')
|
|
24
21
|
for (const contributor of packageJson.contributors!) {
|
|
25
|
-
|
|
22
|
+
showPerson(contributor)
|
|
26
23
|
}
|
|
27
24
|
})
|
|
28
25
|
|
|
29
|
-
function
|
|
26
|
+
function showPerson(person: string | { name: string; email?: string; url?: string }) {
|
|
30
27
|
let line = ' - '
|
|
31
28
|
if (typeof person === 'string') {
|
|
32
29
|
line += person
|
package/toolkit/index.ts
CHANGED
|
@@ -18,13 +18,12 @@ import { generateCmd } from './generate'
|
|
|
18
18
|
import { makeCmd } from './make'
|
|
19
19
|
import { upgradeCmd } from './upgrade'
|
|
20
20
|
import { uploadCmd } from './upload'
|
|
21
|
+
import { packageJson } from '../lib/versions'
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
program.
|
|
25
|
-
program.
|
|
26
|
-
program.version(packageJson.version as string)
|
|
27
|
-
program.description(packageJson.description as string)
|
|
23
|
+
program.name(Object.keys(packageJson.bin as Record<string, string>)[0] as string)
|
|
24
|
+
program.alias(Object.keys(packageJson.bin as Record<string, string>)[1] as string)
|
|
25
|
+
program.version(packageJson.version)
|
|
26
|
+
program.description(packageJson.description!)
|
|
28
27
|
program.helpCommand('help [command]', 'Display help for command') // To get the message with uppercase :-)
|
|
29
28
|
|
|
30
29
|
program.addCommand(configCmd)
|
package/toolkit/upgrade.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Command } from '@commander-js/extra-typings'
|
|
2
|
-
import { upgrade } from 'lib/versions'
|
|
2
|
+
import { upgrade } from '../lib/versions'
|
|
3
3
|
|
|
4
4
|
export const upgradeCmd = new Command('upgrade')
|
|
5
|
-
.description('Upgrade
|
|
5
|
+
.description('Upgrade to the latest version')
|
|
6
6
|
|
|
7
7
|
.action(async () => {
|
|
8
8
|
await upgrade()
|
package/toolkit/upload.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const uploadCmd = new Command('upload')
|
|
|
7
7
|
.description(
|
|
8
8
|
`Upload problem to Jutge.org
|
|
9
9
|
|
|
10
|
-
If problem.yml exists, the problem will be updated at Jutge.org using that information.
|
|
10
|
+
If problem.yml exists, the problem will be updated at Jutge.org using that information (which includes its problem id).
|
|
11
11
|
If problem.yml does not exist, a new problem will be created at Jutge.org and problem.yml will be generated.
|
|
12
12
|
`,
|
|
13
13
|
)
|