@@ -9,12 +9,15 @@ const EXECUTABLE_PATH = path.join(PROJECT_ROOT, 'bin', 'cli.js');
99const CodemodCLI = require ( '../src' ) ;
1010const ROOT = process . cwd ( ) ;
1111
12+ // We need to update the linting story before we can fix this lint error. That is a much
13+ // bigger change and can happen in a follow-up PR
14+ // eslint-disable-next-line node/no-unsupported-features/es-syntax
1215import { describe , test , beforeEach , beforeAll , afterEach , assert } from 'vitest' ;
1316
14- describe ( 'codemod-cli' , function ( hooks ) {
17+ describe ( 'codemod-cli' , function ( ) {
1518 let codemodProject ;
1619
17- function setupProject ( hooks , installDeps = false ) {
20+ function setupProject ( installDeps = false ) {
1821 let sharedProject ;
1922
2023 beforeAll ( async function ( ) {
@@ -80,17 +83,17 @@ describe('codemod-cli', function (hooks) {
8083 } ) ;
8184 } ) ;
8285
83- describe ( 'linting' , function ( hooks ) {
84- setupProject ( hooks , true ) ;
86+ describe ( 'linting' , function ( ) {
87+ setupProject ( true ) ;
8588
8689 test ( 'should pass for a basic project' , async function ( ) {
8790 let result = await execa ( 'npm' , [ 'run' , 'lint' ] ) ;
8891 assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
8992 } ) ;
9093 } ) ;
9194
92- describe ( 'update-docs' , function ( hooks ) {
93- setupProject ( hooks ) ;
95+ describe ( 'update-docs' , function ( ) {
96+ setupProject ( ) ;
9497
9598 test ( 'updates top-level README with links to transform READMEs' , async function ( ) {
9699 codemodProject . write ( {
@@ -139,8 +142,8 @@ describe('codemod-cli', function (hooks) {
139142 } ) ;
140143 } ) ;
141144
142- describe ( 'generate' , function ( hooks ) {
143- setupProject ( hooks ) ;
145+ describe ( 'generate' , function ( ) {
146+ setupProject ( ) ;
144147
145148 describe ( 'codemod' , function ( ) {
146149 test ( 'should generate a js codemod' , async function ( ) {
@@ -222,32 +225,29 @@ describe('codemod-cli', function (hooks) {
222225 ] ) ;
223226 } ) ;
224227
225- test (
226- 'should generate a fixture for the specified hbs codemod' ,
227- async function ( ) {
228- await execa ( EXECUTABLE_PATH , [ 'generate' , 'codemod' , 'main' , '--type' , 'hbs' ] ) ;
229- let result = await execa ( EXECUTABLE_PATH , [
230- 'generate' ,
231- 'fixture' ,
232- 'main' ,
233- 'this-dot-owner' ,
234- ] ) ;
235-
236- assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
237- assert . deepEqual ( walkSync ( codemodProject . path ( 'transforms' ) ) , [
238- '.gitkeep' ,
239- 'main/' ,
240- 'main/README.md' ,
241- 'main/__testfixtures__/' ,
242- 'main/__testfixtures__/basic.input.hbs' ,
243- 'main/__testfixtures__/basic.output.hbs' ,
244- 'main/__testfixtures__/this-dot-owner.input.hbs' ,
245- 'main/__testfixtures__/this-dot-owner.output.hbs' ,
246- 'main/index.js' ,
247- 'main/test.js' ,
248- ] ) ;
249- }
250- ) ;
228+ test ( 'should generate a fixture for the specified hbs codemod' , async function ( ) {
229+ await execa ( EXECUTABLE_PATH , [ 'generate' , 'codemod' , 'main' , '--type' , 'hbs' ] ) ;
230+ let result = await execa ( EXECUTABLE_PATH , [
231+ 'generate' ,
232+ 'fixture' ,
233+ 'main' ,
234+ 'this-dot-owner' ,
235+ ] ) ;
236+
237+ assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
238+ assert . deepEqual ( walkSync ( codemodProject . path ( 'transforms' ) ) , [
239+ '.gitkeep' ,
240+ 'main/' ,
241+ 'main/README.md' ,
242+ 'main/__testfixtures__/' ,
243+ 'main/__testfixtures__/basic.input.hbs' ,
244+ 'main/__testfixtures__/basic.output.hbs' ,
245+ 'main/__testfixtures__/this-dot-owner.input.hbs' ,
246+ 'main/__testfixtures__/this-dot-owner.output.hbs' ,
247+ 'main/index.js' ,
248+ 'main/test.js' ,
249+ ] ) ;
250+ } ) ;
251251 } ) ;
252252
253253 describe ( 'test' , function ( ) {
@@ -302,17 +302,15 @@ describe('codemod-cli', function (hooks) {
302302 }
303303 } ) ;
304304
305- test (
306- 'transform should receive options from ${name}.options.json' ,
307- async function ( ) {
308- const expectedReplacement = 'AAAAHHHHHH' ;
305+ test ( 'transform should receive options from ${name}.options.json' , async function ( ) {
306+ const expectedReplacement = 'AAAAHHHHHH' ;
309307
310- await execa ( EXECUTABLE_PATH , [ 'generate' , 'codemod' , 'main' ] ) ;
308+ await execa ( EXECUTABLE_PATH , [ 'generate' , 'codemod' , 'main' ] ) ;
311309
312- codemodProject . write ( {
313- transforms : {
314- main : {
315- 'index.js' : `
310+ codemodProject . write ( {
311+ transforms : {
312+ main : {
313+ 'index.js' : `
316314 const { getParser } = require('codemod-cli').jscodeshift;
317315 const { getOptions } = require('codemod-cli');
318316 module.exports = function transformer(file, api) {
@@ -328,19 +326,18 @@ describe('codemod-cli', function (hooks) {
328326 .toSource();
329327 }
330328 ` ,
331- __testfixtures__ : {
332- 'basic.input.js' : 'var foo = "foo";' ,
333- 'basic.output.js' : `var foo = "${ expectedReplacement } ";` ,
334- 'basic.options.json' : `{ "replaceAll": "${ expectedReplacement } " }` ,
335- } ,
329+ __testfixtures__ : {
330+ 'basic.input.js' : 'var foo = "foo";' ,
331+ 'basic.output.js' : `var foo = "${ expectedReplacement } ";` ,
332+ 'basic.options.json' : `{ "replaceAll": "${ expectedReplacement } " }` ,
336333 } ,
337334 } ,
338- } ) ;
335+ } ,
336+ } ) ;
339337
340- let result = await execa ( EXECUTABLE_PATH , [ 'test' ] ) ;
341- assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
342- }
343- ) ;
338+ let result = await execa ( EXECUTABLE_PATH , [ 'test' ] ) ;
339+ assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
340+ } ) ;
344341
345342 test ( 'transform should receive a file path in tests' , async function ( ) {
346343 const realCodemodProjectPath = fs . realpathSync ( codemodProject . path ( ) ) ;
@@ -379,18 +376,16 @@ describe('codemod-cli', function (hooks) {
379376 assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
380377 } ) ;
381378
382- test (
383- 'transform should receive a subfolder file path in tests' ,
384- async function ( ) {
385- const realCodemodProjectPath = fs . realpathSync ( codemodProject . path ( ) ) ;
386- const expectedPath = `${ realCodemodProjectPath } /transforms/main/__testfixtures__/foo/basic.js` ;
379+ test ( 'transform should receive a subfolder file path in tests' , async function ( ) {
380+ const realCodemodProjectPath = fs . realpathSync ( codemodProject . path ( ) ) ;
381+ const expectedPath = `${ realCodemodProjectPath } /transforms/main/__testfixtures__/foo/basic.js` ;
387382
388- await execa ( EXECUTABLE_PATH , [ 'generate' , 'codemod' , 'main' ] ) ;
383+ await execa ( EXECUTABLE_PATH , [ 'generate' , 'codemod' , 'main' ] ) ;
389384
390- codemodProject . write ( {
391- transforms : {
392- main : {
393- 'index.js' : `
385+ codemodProject . write ( {
386+ transforms : {
387+ main : {
388+ 'index.js' : `
394389 const { getParser } = require('codemod-cli').jscodeshift;
395390
396391 module.exports = function transformer(file, api) {
@@ -406,25 +401,24 @@ describe('codemod-cli', function (hooks) {
406401 .toSource();
407402 }
408403 ` ,
409- __testfixtures__ : {
410- foo : {
411- 'basic.input.js' : 'var foo = "foo";' ,
412- 'basic.output.js' : `var foo = "${ expectedPath } ";` ,
413- } ,
404+ __testfixtures__ : {
405+ foo : {
406+ 'basic.input.js' : 'var foo = "foo";' ,
407+ 'basic.output.js' : `var foo = "${ expectedPath } ";` ,
414408 } ,
415409 } ,
416410 } ,
417- } ) ;
411+ } ,
412+ } ) ;
418413
419- let result = await execa ( EXECUTABLE_PATH , [ 'test' ] ) ;
420- assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
421- }
422- ) ;
414+ let result = await execa ( EXECUTABLE_PATH , [ 'test' ] ) ;
415+ assert . equal ( result . exitCode , 0 , 'exited with zero' ) ;
416+ } ) ;
423417 } ) ;
424418 } ) ;
425419
426- describe ( 'generated bin script' , function ( hooks ) {
427- setupProject ( hooks ) ;
420+ describe ( 'generated bin script' , function ( ) {
421+ setupProject ( ) ;
428422
429423 let userProject ;
430424 beforeEach ( async function ( ) {
@@ -486,10 +480,10 @@ describe('codemod-cli', function (hooks) {
486480 } ) ;
487481 } ) ;
488482
489- describe ( 'programmatic API' , function ( hooks ) {
490- setupProject ( hooks ) ;
483+ describe ( 'programmatic API' , function ( ) {
484+ setupProject ( ) ;
491485
492- describe ( 'runTransform' , function ( hooks ) {
486+ describe ( 'runTransform' , function ( ) {
493487 let userProject ;
494488
495489 beforeEach ( async function ( ) {
@@ -750,7 +744,7 @@ describe('codemod-cli', function (hooks) {
750744 } ) ;
751745 } ) ;
752746
753- describe ( 'runTransform type=hbs' , function ( hooks ) {
747+ describe ( 'runTransform type=hbs' , function ( ) {
754748 let userProject ;
755749
756750 beforeEach ( async function ( ) {
0 commit comments