@@ -698,221 +698,6 @@ Effect
698698 Command . withDescription ( "Generate and update package.json exports mappings for all packages in monorepo" )
699699 )
700700
701- const wiki = Command
702- . make (
703- "wiki" ,
704- { } ,
705- Effect . fn ( "effa-cli.wiki" ) ( function * ( ) {
706- const action = yield * Prompt . select ( {
707- choices : [ {
708- title : "sync" ,
709- description : "Initialize and update the documentation submodule" ,
710- value : "sync"
711- } , {
712- title : "update" ,
713- description : "Pull latest changes from remote, commit and push changes within the submodule" ,
714- value : "update"
715- } ] ,
716- message : "Select wiki action"
717- } )
718-
719- const syncCommand = runNodeCommandEC ( "git submodule update --init --recursive --remote doc" )
720-
721- switch ( action ) {
722- case "sync" : {
723- yield * Effect . logInfo ( "Initializing/updating git submodule for documentation..." )
724-
725- if ( ( yield * syncCommand ) !== 0 ) {
726- return yield * Effect . fail ( `Failed to sync submodule` )
727- }
728-
729- break
730- }
731- case "update" : {
732- yield * Effect . logInfo ( "Pulling latest changes from remote submodule..." )
733-
734- if ( ( yield * syncCommand ) !== 0 ) {
735- return yield * Effect . fail ( `Failed to sync submodule` )
736- }
737-
738- const commitMessage = yield * Prompt . text ( {
739- message : "Enter commit message:" ,
740- default : "update doc" ,
741- validate : ( input ) =>
742- input . trim ( ) . length > 0
743- ? Effect . succeed ( input . trim ( ) )
744- : Effect . fail ( "Commit message cannot be empty" )
745- } )
746-
747- yield * Effect . logInfo ( "Committing and pushing changes in submodule..." )
748-
749- if (
750- ( yield * runNodeCommandEC (
751- `git -C doc add . && git -C doc commit -m '${ commitMessage } ' && git -C doc push`
752- ) ) === 0
753- ) {
754- yield * Effect . logInfo ( "Submodule updated and pushed successfully" )
755- }
756-
757- break
758- }
759- default : {
760- action satisfies never
761- return yield * Effect . fail ( `Unknown wiki action: ${ action } . Available actions: sync, update` )
762- }
763- }
764-
765- // check if references to submodule have changed in main repo
766- // and offer to commit these changes
767- const statusOutput = yield * runNodeCommand ( "git status --porcelain" )
768-
769- const hasSubmoduleChanges = statusOutput
770- . split ( "\n" )
771- . some ( ( line ) => line . trim ( ) . endsWith ( "doc" ) && line . trim ( ) . startsWith ( "M " ) )
772-
773- if ( hasSubmoduleChanges ) {
774- const shouldCommitSubmodule = yield * Prompt . confirm ( {
775- message : "Changes to the submodule detected in main repository. Commit these changes?" ,
776- initial : false
777- } )
778-
779- if (
780- shouldCommitSubmodule
781- ) {
782- const mainCommitMessage = yield * Prompt . text ( {
783- message : "Enter commit message for main repository:" ,
784- default : "update doc submodule reference" ,
785- validate : ( input ) =>
786- input . trim ( ) . length > 0
787- ? Effect . succeed ( input . trim ( ) )
788- : Effect . fail ( "Commit message cannot be empty" )
789- } )
790-
791- if (
792- ( yield * runNodeCommandEC (
793- `git commit -m '${ mainCommitMessage } ' doc`
794- ) ) === 0
795- ) {
796- yield * Effect . logInfo ( "Main repository updated with submodule changes successfully" )
797- } else {
798- yield * Effect . logError ( "Failed to commit submodule changes in main repository" )
799- }
800- } else {
801- yield * Effect . logInfo ( "Remember to commit the submodule changes in the main repository later." )
802- }
803- } else {
804- yield * Effect . logInfo ( "No changes to the submodule detected in main repository." )
805- }
806- } )
807- )
808- . pipe ( Command . withDescription (
809- `Manage the documentation wiki git submodule with interactive action selection.
810-
811- Available actions:
812- - sync: Initialize and update the documentation submodule from remote
813- - update: Pull latest changes, commit and push changes within the submodule
814-
815- After any action, automatically detects and offers to commit submodule reference changes in the main repository.`
816- ) )
817-
818- const initWiki = Command
819- . make (
820- "init-wiki" ,
821- { } ,
822- Effect . fn ( "effa-cli.initWiki" ) ( function * ( { } ) {
823- yield * Effect . logInfo ( "⚠️ IMPORTANT: This is a one-time project setup command!" )
824-
825- // check if doc directory already exists in git index
826- const docInIndex = yield * runNodeCommand ( "git ls-files" )
827- . pipe (
828- Effect . map ( ( output ) => output . split ( "\n" ) . some ( ( line ) => line . startsWith ( "doc/" ) || line === "doc" ) ) ,
829- Effect . catchAll ( ( ) => Effect . succeed ( false ) )
830- )
831-
832- if ( docInIndex ) {
833- return yield * Effect . logError ( `❌ ERROR: A 'doc' directory already exists in the git index!
834-
835- This suggests the wiki submodule may have been initialized before, or there are conflicting files.
836-
837- Required actions before proceeding:
838- 1. Move existing doc files to GitHub wiki or another location
839- 2. Remove the doc directory from filesystem: rm -rf doc
840- 3. Remove the doc directory from git index: git rm --cached -r doc
841- 4. Commit the removal: git commit -m "Remove doc directory"
842- 5. Re-run this command
843-
844- Operation cancelled for safety.` )
845- }
846-
847- const confirmation = yield * Prompt . confirm ( {
848- message : `This command will initialize the wiki submodule for this project.
849-
850- ⚠️ WARNING: This is NOT the command to use for local submodule initialization!
851-
852- This command should only be run ONCE in the entire project history by a project maintainer to:
853- - Set up the initial .gitmodules configuration
854- - Add the wiki submodule to the repository
855- - Commit the submodule configuration
856-
857- For normal local development, use 'effa wiki sync' instead.
858-
859- Are you sure you want to proceed with the one-time project setup?` ,
860- initial : false
861- } )
862-
863- if ( ! confirmation ) {
864- return yield * Effect . logInfo ( "Operation cancelled. Use 'effa wiki sync' for normal wiki operations." )
865- }
866-
867- yield * Effect . logInfo ( "Extracting project name from git remote..." )
868- const remoteUrl = yield * runNodeCommand ( "git config --get remote.origin.url" )
869-
870- // extract project name from URL (supports both SSH and HTTPS)
871- //
872- // - [email protected] :user/project-name.git -> project-name 873- // - https://github.com/user/project-name.git -> project-name
874- let detectedProjectName = remoteUrl
875- . split ( "/" )
876- . pop ( )
877- ?. replace ( / \. g i t $ / , "" )
878- ?. trim ( )
879-
880- yield * detectedProjectName
881- ? Effect . logInfo ( `Detected project name from git remote: ${ detectedProjectName } ` )
882- : Effect . logWarning ( "Could not determine project name from git remote" )
883-
884- detectedProjectName = yield * Prompt . text ( {
885- message : detectedProjectName
886- ? "Please confirm or modify the project name:"
887- : "Please enter the project name:" ,
888- ...detectedProjectName && { default : detectedProjectName } ,
889- validate : ( input ) =>
890- input . trim ( ) . length > 0
891- ? Effect . succeed ( input . trim ( ) )
892- : Effect . fail ( "Project name cannot be empty" )
893- } )
894-
895- yield * Effect . logInfo ( `Using project name: ${ detectedProjectName } ` )
896-
897- yield * Effect . logInfo ( "Creating .gitmodules file..." )
898- yield * runNodeCommandEC ( `echo '' >> .gitmodules` )
899- yield * runNodeCommandEC ( `echo '[submodule "doc"]' >> .gitmodules` )
900- yield * runNodeCommandEC ( `echo ' path = doc' >> .gitmodules` )
901- yield * runNodeCommandEC ( `echo ' url = ../${ detectedProjectName } .wiki.git' >> .gitmodules` )
902- yield * runNodeCommandEC ( `echo ' branch = master' >> .gitmodules` )
903- yield * runNodeCommandEC ( `echo ' update = merge' >> .gitmodules` )
904-
905- yield * Effect . logInfo ( "Adding git submodule for documentation wiki..." )
906- yield * runNodeCommandEC ( `git submodule add -b master ../${ detectedProjectName } .wiki.git doc` )
907-
908- yield * Effect . logInfo ( "Committing wiki submodule addition..." )
909- yield * runNodeCommandEC ( "git add . && git commit -am 'Add doc submodule'" )
910-
911- return yield * Effect . logInfo ( "Wiki submodule initialized successfully" )
912- } )
913- )
914- . pipe ( Command . withDescription ( "Set up the wiki submodule for the project (one-time setup)" ) )
915-
916701 const nuke = Command
917702 . make (
918703 "nuke" ,
@@ -960,8 +745,6 @@ Are you sure you want to proceed with the one-time project setup?`,
960745 indexMulti ,
961746 packagejson ,
962747 packagejsonPackages ,
963- wiki ,
964- initWiki ,
965748 nuke
966749 ] ) ) ,
967750 {
0 commit comments