Skip to content

Commit

Permalink
fix: command name should not be changed as it's breaking change
Browse files Browse the repository at this point in the history
paulfouquet committed Sep 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f6f9b94 commit f38d58c
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/commands/basemaps-github/make.cog.github.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import { TileSetConfigSchema } from '@basemaps/config/build/json/parse.tile.set.
import { fsa, LogType } from '@basemaps/shared';

import { DEFAULT_PRETTIER_FORMAT } from '../../utils/config.js';
import { prettyPrint } from '../format/format.json.js';
import { prettyPrint } from '../format/pretty.print.js';
import { createPR, GithubApi } from './github.js';

export enum Category {
Original file line number Diff line number Diff line change
@@ -14,9 +14,9 @@ function isJson(x: string): boolean {
return search.endsWith('.json');
}

export const commandFormatJson = command({
name: 'format-json',
description: 'Format JSON files',
export const commandPrettyPrint = command({
name: 'pretty-print',
description: 'Pretty-print JSON files',
version: CliInfo.version,
args: {
config,
@@ -39,9 +39,9 @@ export const commandFormatJson = command({
async handler(args) {
registerCli(this, args);
const startTime = performance.now();
logger.info('FormatJson:Start');
logger.info('PrettyPrint:Start');
if (args.target) {
logger.info({ target: args.target }, 'FormatJson:Info');
logger.info({ target: args.target }, 'PrettyPrint:Info');
}

const files = await getFiles([args.path]);
@@ -53,7 +53,7 @@ export const commandFormatJson = command({

// format files
await Promise.all(jsonFiles.map((f: string) => formatFile(f, args.target, args.fixContentType)));
logger.info({ fileCount: jsonFiles.length, duration: performance.now() - startTime }, 'FormatJson:Done');
logger.info({ fileCount: jsonFiles.length, duration: performance.now() - startTime }, 'PrettyPrint:Done');
},
});

@@ -65,7 +65,7 @@ export const commandFormatJson = command({
* @param fixContentType if true will set the `contentType` with a guessed value. @see guessStacContentType
*/
export async function formatFile(path: string, target = '', fixContentType: boolean = false): Promise<void> {
logger.debug({ file: path }, 'FormatJson:RunPrettier');
logger.debug({ file: path }, 'PrettyPrint:RunPrettier');
const prettyPrinted = await prettyPrint(JSON.stringify(await fsa.readJson(path)), DEFAULT_PRETTIER_FORMAT);
if (target) {
// FIXME: can be duplicate files
4 changes: 2 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { CliInfo } from '../cli.info.js';
import { basemapsCreatePullRequest } from './basemaps-github/create-pr.js';
import { commandCopy } from './copy/copy.js';
import { commandCreateManifest } from './create-manifest/create-manifest.js';
import { commandFormatJson } from './format/format.json.js';
import { commandPrettyPrint } from './format/pretty.print.js';
import { commandGroup } from './group/group.js';
import { commandLdsFetch } from './lds-cache/lds.cache.js';
import { commandList } from './list/list.js';
@@ -46,6 +46,6 @@ export const cmd = subcommands({
'create-pr': basemapsCreatePullRequest,
},
}),
'format-json': commandFormatJson,
'pretty-print': commandPrettyPrint,
},
});
2 changes: 1 addition & 1 deletion src/commands/stac-github-import/stac.github.import.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import * as st from 'stac-ts';
import { CliInfo } from '../../cli.info.js';
import { logger } from '../../log.js';
import { config, registerCli, verbose } from '../common.js';
import { formatFile } from '../format/format.json.js';
import { formatFile } from '../format/pretty.print.js';

const Url: Type<string, URL> = {
async from(str) {

0 comments on commit f38d58c

Please sign in to comment.