@davidvornholt/standards 0.3.0 → 0.4.0
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/package.json +1 -1
- package/src/cli.ts +40 -8
- package/src/github-api.ts +1 -1
- package/src/github-commands.ts +1 -1
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -74,10 +74,10 @@ type Source = {
|
|
|
74
74
|
readonly cleanup: () => void;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
type Command = 'check' | 'doctor' | 'github' | 'init' | 'sync';
|
|
77
|
+
type Command = 'check' | 'doctor' | 'github' | 'help' | 'init' | 'sync';
|
|
78
78
|
|
|
79
79
|
type CliOptions = {
|
|
80
|
-
readonly command: Command;
|
|
80
|
+
readonly command: Command | undefined;
|
|
81
81
|
readonly consumer: string;
|
|
82
82
|
readonly dryRun: boolean;
|
|
83
83
|
readonly from: string | undefined;
|
|
@@ -461,7 +461,7 @@ const runCheck = async (consumer: string): Promise<boolean> => {
|
|
|
461
461
|
);
|
|
462
462
|
console.error(problems.join('\n'));
|
|
463
463
|
console.error(
|
|
464
|
-
'These files are read-only. Restore them with `
|
|
464
|
+
'These files are read-only. Restore them with `bun standards sync`, or move your change upstream.',
|
|
465
465
|
);
|
|
466
466
|
return false;
|
|
467
467
|
}
|
|
@@ -735,11 +735,29 @@ const runDoctor = async (consumer: string): Promise<boolean> => {
|
|
|
735
735
|
return true;
|
|
736
736
|
};
|
|
737
737
|
|
|
738
|
+
const USAGE = `Usage: standards <command> [options]
|
|
739
|
+
|
|
740
|
+
Commands:
|
|
741
|
+
init Bootstrap a consumer repo: seed repo-owned files, mirror canonical files, write the lock
|
|
742
|
+
sync Mirror canonical files from upstream and rewrite the lock
|
|
743
|
+
check Verify canonical files, extension seams, and GitHub settings
|
|
744
|
+
doctor Validate extension seams only
|
|
745
|
+
github Compare (--check) or converge (--apply) live GitHub settings
|
|
746
|
+
help Show this help
|
|
747
|
+
|
|
748
|
+
Options:
|
|
749
|
+
--dir <path> Consumer directory to operate on (default: current directory)
|
|
750
|
+
--from <src> Upstream override for init/sync (GitHub repo or local path)
|
|
751
|
+
--dry-run Preview a sync without writing anything
|
|
752
|
+
--check With github: compare live settings to the declaration (default)
|
|
753
|
+
--apply With github: converge the live repository (needs admin auth)`;
|
|
754
|
+
|
|
738
755
|
const commandFromArg = (arg: string): Command => {
|
|
739
756
|
if (
|
|
740
757
|
arg === 'check' ||
|
|
741
758
|
arg === 'doctor' ||
|
|
742
759
|
arg === 'github' ||
|
|
760
|
+
arg === 'help' ||
|
|
743
761
|
arg === 'init' ||
|
|
744
762
|
arg === 'sync'
|
|
745
763
|
) {
|
|
@@ -796,15 +814,17 @@ const parseArgs = (argv: ReadonlyArray<string>): CliOptions => {
|
|
|
796
814
|
from = nextOptionValue(argv, index);
|
|
797
815
|
index += 1;
|
|
798
816
|
break;
|
|
817
|
+
case '--help':
|
|
818
|
+
case '-h':
|
|
819
|
+
command = setCommand(command, 'help');
|
|
820
|
+
break;
|
|
799
821
|
default:
|
|
800
822
|
command = setCommand(command, commandFromArg(arg));
|
|
801
823
|
}
|
|
802
824
|
}
|
|
803
825
|
|
|
804
|
-
// `--check` doubles as the legacy spelling of the check command and as the
|
|
805
|
-
// explicit (default) mode of `github`.
|
|
806
826
|
if (checkFlag && command !== 'github') {
|
|
807
|
-
|
|
827
|
+
throw new Error('--check is only valid with the github command');
|
|
808
828
|
}
|
|
809
829
|
if (apply && command !== 'github') {
|
|
810
830
|
throw new Error('--apply is only valid with the github command');
|
|
@@ -814,7 +834,7 @@ const parseArgs = (argv: ReadonlyArray<string>): CliOptions => {
|
|
|
814
834
|
}
|
|
815
835
|
|
|
816
836
|
return {
|
|
817
|
-
command
|
|
837
|
+
command,
|
|
818
838
|
consumer: resolve(consumer),
|
|
819
839
|
dryRun,
|
|
820
840
|
from,
|
|
@@ -843,7 +863,7 @@ const runInitCommand = async (
|
|
|
843
863
|
// upstream deleted (they leave the lock and no future sync removes them).
|
|
844
864
|
if (existsSync(join(consumer, 'sync-standards.lock'))) {
|
|
845
865
|
console.error(
|
|
846
|
-
'standards: already initialized (sync-standards.lock exists). Use `
|
|
866
|
+
'standards: already initialized (sync-standards.lock exists). Use `bun standards sync` to update.',
|
|
847
867
|
);
|
|
848
868
|
process.exitCode = 1;
|
|
849
869
|
return;
|
|
@@ -883,6 +903,18 @@ const main = async (): Promise<void> => {
|
|
|
883
903
|
process.argv.slice(2),
|
|
884
904
|
);
|
|
885
905
|
|
|
906
|
+
if (command === undefined) {
|
|
907
|
+
console.error('standards: a command is required\n');
|
|
908
|
+
console.error(USAGE);
|
|
909
|
+
process.exitCode = 1;
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
if (command === 'help') {
|
|
914
|
+
console.log(USAGE);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
|
|
886
918
|
if (command === 'check') {
|
|
887
919
|
if (!(await runCheckCommand(consumer))) {
|
|
888
920
|
process.exitCode = 1;
|
package/src/github-api.ts
CHANGED
|
@@ -99,7 +99,7 @@ export const loadDeclared = async (
|
|
|
99
99
|
return {
|
|
100
100
|
merged: null,
|
|
101
101
|
problems: [
|
|
102
|
-
`${CANONICAL_SETTINGS_FILE} not found; run \`
|
|
102
|
+
`${CANONICAL_SETTINGS_FILE} not found; run \`bun standards sync\` first`,
|
|
103
103
|
],
|
|
104
104
|
};
|
|
105
105
|
}
|
package/src/github-commands.ts
CHANGED
|
@@ -78,7 +78,7 @@ export const runGithubCheck = async (consumer: string): Promise<boolean> => {
|
|
|
78
78
|
if (problems.length > 0) {
|
|
79
79
|
reportProblems(problems);
|
|
80
80
|
console.error(
|
|
81
|
-
'Converge with `
|
|
81
|
+
'Converge with `bun standards github --apply` (admin auth), or fix the declaration.',
|
|
82
82
|
);
|
|
83
83
|
return false;
|
|
84
84
|
}
|