Skip to content

Commit

Permalink
quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Jun 11, 2022
1 parent 43d0af3 commit 3691d0e
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 8 deletions.
65 changes: 65 additions & 0 deletions .husky/pre-push
@@ -0,0 +1,65 @@
#!/bin/sh

# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
# 3. Or, use `rake hooks:pre_push` to install
#
# Try a force push to master, you should get a message `*** [Policy] never force push...`
#
# The commands below will not be allowed...
# `git push --force origin master`
# `git push --delete origin master`
# `git push origin :master`
#
# Nor will a force push while on the master branch be allowed...
# `git co master`
# `git push --force origin`
#
# Requires git 1.8.2 or newer
#
# Git 1.8.2 release notes cover the new pre-push hook:
# <https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.2.txt>
#
# See Sample pre-push script:
# <https://github.com/git/git/blob/87c86dd14abe8db7d00b0df5661ef8cf147a72a3/templates/hooks--pre-push.sample>


protected_branch='master'

policy='[Policy] Never force push or delete the '$protected_branch' branch! (Prevented with pre-push hook.)'

current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')

# cSpell:ignore ocommand PPID
push_command=$(ps -ocommand= -p $PPID)

is_destructive='force|delete|\-f'

will_remove_protected_branch=':'$protected_branch

do_exit(){
echo $policy
exit 1
}

if [[ $push_command =~ $is_destructive ]] && [ $current_branch = $protected_branch ]; then
do_exit
fi

if [[ $push_command =~ $is_destructive ]] && [[ $push_command =~ $protected_branch ]]; then
do_exit
fi

if [[ $push_command =~ $will_remove_protected_branch ]]; then
do_exit
fi

unset do_exit

exit 0
Expand Up @@ -47,7 +47,10 @@ exports[`wrap TypeScript wrap ComponentInFolder 2`] = `
import ComponentInFolder from '@theme-original/ComponentInFolder';
import type ComponentInFolderType from '@theme/ComponentInFolder';
type Props = ComponentProps<typeof ComponentInFolderType>;
type RawProps = ComponentProps<typeof ComponentInFolderType>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
return (
Expand All @@ -64,7 +67,10 @@ exports[`wrap TypeScript wrap ComponentInFolder/ComponentInSubFolder 2`] = `
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
type Props = ComponentProps<typeof ComponentInSubFolderType>;
type RawProps = ComponentProps<typeof ComponentInSubFolderType>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
return (
Expand All @@ -81,7 +87,10 @@ exports[`wrap TypeScript wrap FirstLevelComponent 2`] = `
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
type Props = ComponentProps<typeof FirstLevelComponentType>;
type RawProps = ComponentProps<typeof FirstLevelComponentType>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
return (
Expand Down
Expand Up @@ -277,7 +277,10 @@ exports[`swizzle wrap ComponentInFolder TS: ComponentInFolder/index.tsx 1`] = `
import ComponentInFolder from '@theme-original/ComponentInFolder';
import type ComponentInFolderType from '@theme/ComponentInFolder';
type Props = ComponentProps<typeof ComponentInFolderType>;
type RawProps = ComponentProps<typeof ComponentInFolderType>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
return (
Expand Down Expand Up @@ -321,7 +324,10 @@ exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder TS: ComponentInFold
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
type Props = ComponentProps<typeof ComponentInSubFolderType>;
type RawProps = ComponentProps<typeof ComponentInSubFolderType>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
return (
Expand Down Expand Up @@ -365,7 +371,10 @@ exports[`swizzle wrap ComponentInFolder/Sibling TS: ComponentInFolder/Sibling.ts
import Sibling from '@theme-original/ComponentInFolder/Sibling';
import type SiblingType from '@theme/ComponentInFolder/Sibling';
type Props = ComponentProps<typeof SiblingType>;
type RawProps = ComponentProps<typeof SiblingType>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
export default function SiblingWrapper(props: Props): JSX.Element {
return (
Expand Down Expand Up @@ -407,7 +416,10 @@ exports[`swizzle wrap FirstLevelComponent TS: FirstLevelComponent.tsx 1`] = `
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
type Props = ComponentProps<typeof FirstLevelComponentType>;
type RawProps = ComponentProps<typeof FirstLevelComponentType>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
return (
Expand Down
5 changes: 4 additions & 1 deletion packages/docusaurus/src/commands/swizzle/actions.ts
Expand Up @@ -125,7 +125,10 @@ export async function wrap({
import ${componentName} from '@theme-${importType}/${themeComponentName}';
import type ${componentName}Type from '@theme/${themeComponentName}';
type Props = ComponentProps<typeof ${componentName}Type>;
type RawProps = ComponentProps<typeof ${componentName}Type>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
export default function ${wrapperComponentName}(props: Props): JSX.Element {
return (
Expand Down

0 comments on commit 3691d0e

Please sign in to comment.