phetsims / perennial

Maintenance tools that won't change with different versions of chipper checked out
MIT License
2 stars 5 forks source link

`grunt create-sim` fails in the "unpublished-README" task #337

Closed pixelzoom closed 10 months ago

pixelzoom commented 10 months ago

I'm following the steps to create a new sim repo in https://github.com/phetsims/phet-info/blob/main/checklists/new-repo-checklist.md.

grunt create-sim fails in the "unpublished-README" task. Here's an example:

% cd perennial
% grunt create-sim --repo="faradays-electromagnetic-lab" --author="Chris Malley (PixelZoom, Inc.)" --title="Faradays Electromagnetic Lab"
...
Running "unpublished-README" task
Fatal error: Perennial task failed:
Error: git status --porcelain README.md in ../faradays-electromagnetic-lab failed with exit code 128
stderr:
fatal: not a git repository (or any of the parent directories): .git

    at ChildProcess.<anonymous> (/Users/cmalley/PhET/GitHub/perennial-alias/js/common/execute.js:89:21)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:322:12)
Full Error details:
Error: git status --porcelain README.md in ../faradays-electromagnetic-lab failed with exit code 128
stderr:
fatal: not a git repository (or any of the parent directories): .git
pixelzoom commented 10 months ago

The README task is the last thing that's done in createSim.js

  await execute( gruntCommand, [ 'unpublished-README' ], `../${repo}` );
};

I'm guessing the problem was introduced on 6/20/22 (!) in https://github.com/phetsims/chipper/commit/6325d0dfe256cf16dec2f5a8424dce436ad5b6e0 for https://github.com/phetsims/chipper/issues/1256, where @jessegreenberg made this change in generateREADME.js:

-  grunt.file.write( `../${repo}/README.md`, fixEOL( readme ) );
+  await writeFileAndGitAdd( repo, 'README.md', fixEOL( readme ) );

Since the new repo has not yet been initialized in ones working copy, writeFileAndGitAdd will fail. Maybe we need an option to generateREADME that tells it not to do the git add.

Assigning to @jessegreenberg.

jessegreenberg commented 10 months ago

Thanks for reporting, I confirmed the problem and will take a look.

jessegreenberg commented 10 months ago

Instead of an option, I went with a check to see if the git repo is initialized. If not, the git add is skipped. Then I tested the create-sim task.

``` $ grunt create-sim --repo=cannon-blaster --author="Jesse Greenberg (PhET Interactive Simulations)" Running "create-sim" task Greetings Jesse Greenberg (PhET Interactive Simulations)! creating sim with repository name cannon-blaster wrote ../cannon-blaster/.gitignore wrote ../cannon-blaster/dependencies.json wrote ../cannon-blaster/doc/implementation-notes.md wrote ../cannon-blaster/doc/model.md wrote ../cannon-blaster/Gruntfile.js wrote ../cannon-blaster/images/license.json wrote ../cannon-blaster/js/common/CannonBlasterColors.ts wrote ../cannon-blaster/js/common/CannonBlasterConstants.ts wrote ../cannon-blaster/js/common/CannonBlasterQueryParameters.ts wrote ../cannon-blaster/js/cannon-blaster/model/CannonBlasterModel.ts wrote ../cannon-blaster/js/cannon-blaster/CannonBlasterScreen.ts wrote ../cannon-blaster/js/cannon-blaster/view/CannonBlasterScreenView.ts wrote ../cannon-blaster/js/cannon-blaster-main.ts wrote ../cannon-blaster/js/cannonBlaster.ts wrote ../cannon-blaster/js/CannonBlasterStrings.ts wrote ../cannon-blaster/LICENSE wrote ../cannon-blaster/package.json wrote ../cannon-blaster/cannon-blaster-strings_en.json wrote ../cannon-blaster/cannon-blaster_en.html wrote ../cannon-blaster/tsconfig.json info: npm update in ../cannon-blaster Done. ```

@pixelzoom would you like to confirm or review?

pixelzoom commented 10 months ago

Nice solution! Thanks @jessegreenberg. Closing.