@backstage/codemods 0.1.46 → 0.1.48

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @backstage/codemods
2
2
 
3
+ ## 0.1.48
4
+
5
+ ### Patch Changes
6
+
7
+ - 1bd4596: Removed the `ts-node` dev dependency.
8
+ - Updated dependencies
9
+ - @backstage/cli-common@0.1.13
10
+
11
+ ## 0.1.47
12
+
13
+ ### Patch Changes
14
+
15
+ - 6ba64c4: Updated dependency `commander` to `^12.0.0`.
16
+ - Updated dependencies
17
+ - @backstage/cli-common@0.1.13
18
+
3
19
  ## 0.1.46
4
20
 
5
21
  ### Patch Changes
@@ -24,14 +24,6 @@ const isLocal = require('fs').existsSync(path.resolve(__dirname, '../src'));
24
24
  if (!isLocal) {
25
25
  require('..');
26
26
  } else {
27
- require('ts-node').register({
28
- transpileOnly: true,
29
- /* eslint-disable-next-line no-restricted-syntax */
30
- project: path.resolve(__dirname, '../../../tsconfig.json'),
31
- compilerOptions: {
32
- module: 'CommonJS',
33
- },
34
- });
35
-
27
+ require('@backstage/cli/config/nodeTransform.cjs');
36
28
  require('../src');
37
29
  }
package/dist/index.cjs.js CHANGED
@@ -38,6 +38,7 @@ class ExitCodeError extends CustomError {
38
38
  var __super = (...args) => {
39
39
  super(...args);
40
40
  __publicField(this, "code");
41
+ return this;
41
42
  };
42
43
  if (command) {
43
44
  __super(`Command '${command}' exited with code ${code}`);
@@ -120,7 +121,7 @@ function createCodemodAction(name) {
120
121
  };
121
122
  }
122
123
 
123
- var version = "0.1.46";
124
+ var version = "0.1.48";
124
125
 
125
126
  async function main(argv) {
126
127
  commander.program.name("backstage-codemods").version(version);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/codemods.ts","../src/errors.ts","../src/action.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface Codemod {\n name: string;\n description: string;\n}\n\nexport const codemods: Codemod[] = [\n {\n name: 'core-imports',\n description:\n 'Updates @backstage/core imports to use @backstage/core-* imports instead.',\n },\n {\n name: 'extension-names',\n description:\n 'Adds a \"name\" property to all core extensions provided by plugins.',\n },\n];\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport chalk from 'chalk';\n\nexport class CustomError extends Error {\n get name(): string {\n return this.constructor.name;\n }\n}\n\nexport class ExitCodeError extends CustomError {\n readonly code: number;\n\n constructor(code: number, command?: string) {\n if (command) {\n super(`Command '${command}' exited with code ${code}`);\n } else {\n super(`Child exited with code ${code}`);\n }\n this.code = code;\n }\n}\n\nexport function exitWithError(error: Error): never {\n if (error instanceof ExitCodeError) {\n process.stderr.write(`\\n${chalk.red(error.message)}\\n\\n`);\n process.exit(error.code);\n } else {\n process.stderr.write(`\\n${chalk.red(`${error}`)}\\n\\n`);\n process.exit(1);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { relative as relativePath } from 'path';\nimport { spawn } from 'child_process';\nimport { OptionValues } from 'commander';\nimport { findPaths } from '@backstage/cli-common';\nimport { platform } from 'os';\nimport { ExitCodeError } from './errors';\n\n// eslint-disable-next-line no-restricted-syntax\nconst paths = findPaths(__dirname);\n\nexport function createCodemodAction(name: string) {\n return async (dirs: string[], opts: OptionValues) => {\n const transformPath = relativePath(\n process.cwd(),\n paths.resolveOwn('transforms', `${name}.js`),\n );\n\n const args = [\n '--parser=tsx',\n '--extensions=tsx,js,ts,tsx',\n '--transform',\n transformPath,\n '--ignore-pattern=**/node_modules/**',\n ];\n\n if (opts.dry) {\n args.push('--dry');\n }\n\n if (dirs.length) {\n args.push(...dirs);\n } else {\n args.push('.');\n }\n\n console.log(`Running jscodeshift with these arguments: ${args.join(' ')}`);\n\n let command;\n if (platform() === 'win32') {\n command = 'jscodeshift';\n } else {\n // jscodeshift ships a slightly broken bin script with windows\n // line endings so we need to execute it using node rather than\n // letting the `#!/usr/bin/env node` take care of it\n command = process.argv0;\n args.unshift(require.resolve('.bin/jscodeshift'));\n }\n\n const child = spawn(command, args, {\n stdio: 'inherit',\n shell: true,\n env: {\n ...process.env,\n FORCE_COLOR: 'true',\n },\n });\n\n if (typeof child.exitCode === 'number') {\n if (child.exitCode) {\n throw new ExitCodeError(child.exitCode, name);\n }\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n child.once('error', error => reject(error));\n child.once('exit', code => {\n if (code) {\n reject(new ExitCodeError(code, name));\n } else {\n resolve();\n }\n });\n });\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A collection of codemods for Backstage projects\n *\n * @packageDocumentation\n */\n\nimport { program } from 'commander';\nimport chalk from 'chalk';\nimport { codemods } from './codemods';\nimport { exitWithError } from './errors';\nimport { createCodemodAction } from './action';\nimport { version } from '../package.json';\n\nasync function main(argv: string[]) {\n program.name('backstage-codemods').version(version);\n\n const applyCommand = program\n .command('apply <codemod> [target-dirs...]')\n .description(\n 'Apply a codemod to target directories, defaulting to the current directory',\n );\n\n for (const codemod of codemods) {\n applyCommand\n .command(`${codemod.name} [target-dirs...]`)\n .description(codemod.description)\n .option('-d, --dry', 'Dry run, no changes written to files')\n .action(createCodemodAction(codemod.name));\n }\n\n program\n .command('list')\n .description('List available codemods')\n .action(() => {\n const maxNameLength = Math.max(...codemods.map(m => m.name.length));\n for (const codemod of codemods) {\n const paddedName = codemod.name.padEnd(maxNameLength, ' ');\n console.log(`${paddedName} - ${codemod.description}`);\n }\n });\n\n program.on('command:*', () => {\n console.log();\n console.log(chalk.red(`Invalid command: ${program.args.join(' ')}`));\n console.log();\n program.outputHelp();\n process.exit(1);\n });\n\n program.parse(argv);\n}\n\nprocess.on('unhandledRejection', (rejection: unknown) => {\n if (rejection instanceof Error) {\n exitWithError(rejection);\n } else {\n exitWithError(new Error(`Unknown rejection: '${rejection}'`));\n }\n});\n\nmain(process.argv).catch(exitWithError);\n"],"names":["chalk","findPaths","relativePath","platform","spawn","program"],"mappings":";;;;;;;;;;;;;AAqBO,MAAM,QAAsB,GAAA;AAAA,EACjC;AAAA,IACE,IAAM,EAAA,cAAA;AAAA,IACN,WACE,EAAA,2EAAA;AAAA,GACJ;AAAA,EACA;AAAA,IACE,IAAM,EAAA,iBAAA;AAAA,IACN,WACE,EAAA,oEAAA;AAAA,GACJ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CAAA;AAAA,GAClB,MAAA;AACL,IAAA,aAAA,CAAc,IAAI,KAAA,CAAM,CAAuB,oBAAA,EAAA,SAAS,GAAG,CAAC,CAAA,CAAA;AAAA,GAC9D;AACF,CAAC,CAAA,CAAA;AAED,IAAA,CAAK,OAAQ,CAAA,IAAI,CAAE,CAAA,KAAA,CAAM,aAAa,CAAA;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/codemods.ts","../src/errors.ts","../src/action.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface Codemod {\n name: string;\n description: string;\n}\n\nexport const codemods: Codemod[] = [\n {\n name: 'core-imports',\n description:\n 'Updates @backstage/core imports to use @backstage/core-* imports instead.',\n },\n {\n name: 'extension-names',\n description:\n 'Adds a \"name\" property to all core extensions provided by plugins.',\n },\n];\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport chalk from 'chalk';\n\nexport class CustomError extends Error {\n get name(): string {\n return this.constructor.name;\n }\n}\n\nexport class ExitCodeError extends CustomError {\n readonly code: number;\n\n constructor(code: number, command?: string) {\n if (command) {\n super(`Command '${command}' exited with code ${code}`);\n } else {\n super(`Child exited with code ${code}`);\n }\n this.code = code;\n }\n}\n\nexport function exitWithError(error: Error): never {\n if (error instanceof ExitCodeError) {\n process.stderr.write(`\\n${chalk.red(error.message)}\\n\\n`);\n process.exit(error.code);\n } else {\n process.stderr.write(`\\n${chalk.red(`${error}`)}\\n\\n`);\n process.exit(1);\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { relative as relativePath } from 'path';\nimport { spawn } from 'child_process';\nimport { OptionValues } from 'commander';\nimport { findPaths } from '@backstage/cli-common';\nimport { platform } from 'os';\nimport { ExitCodeError } from './errors';\n\n// eslint-disable-next-line no-restricted-syntax\nconst paths = findPaths(__dirname);\n\nexport function createCodemodAction(name: string) {\n return async (dirs: string[], opts: OptionValues) => {\n const transformPath = relativePath(\n process.cwd(),\n paths.resolveOwn('transforms', `${name}.js`),\n );\n\n const args = [\n '--parser=tsx',\n '--extensions=tsx,js,ts,tsx',\n '--transform',\n transformPath,\n '--ignore-pattern=**/node_modules/**',\n ];\n\n if (opts.dry) {\n args.push('--dry');\n }\n\n if (dirs.length) {\n args.push(...dirs);\n } else {\n args.push('.');\n }\n\n console.log(`Running jscodeshift with these arguments: ${args.join(' ')}`);\n\n let command;\n if (platform() === 'win32') {\n command = 'jscodeshift';\n } else {\n // jscodeshift ships a slightly broken bin script with windows\n // line endings so we need to execute it using node rather than\n // letting the `#!/usr/bin/env node` take care of it\n command = process.argv0;\n args.unshift(require.resolve('.bin/jscodeshift'));\n }\n\n const child = spawn(command, args, {\n stdio: 'inherit',\n shell: true,\n env: {\n ...process.env,\n FORCE_COLOR: 'true',\n },\n });\n\n if (typeof child.exitCode === 'number') {\n if (child.exitCode) {\n throw new ExitCodeError(child.exitCode, name);\n }\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n child.once('error', error => reject(error));\n child.once('exit', code => {\n if (code) {\n reject(new ExitCodeError(code, name));\n } else {\n resolve();\n }\n });\n });\n };\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A collection of codemods for Backstage projects\n *\n * @packageDocumentation\n */\n\nimport { program } from 'commander';\nimport chalk from 'chalk';\nimport { codemods } from './codemods';\nimport { exitWithError } from './errors';\nimport { createCodemodAction } from './action';\nimport { version } from '../package.json';\n\nasync function main(argv: string[]) {\n program.name('backstage-codemods').version(version);\n\n const applyCommand = program\n .command('apply <codemod> [target-dirs...]')\n .description(\n 'Apply a codemod to target directories, defaulting to the current directory',\n );\n\n for (const codemod of codemods) {\n applyCommand\n .command(`${codemod.name} [target-dirs...]`)\n .description(codemod.description)\n .option('-d, --dry', 'Dry run, no changes written to files')\n .action(createCodemodAction(codemod.name));\n }\n\n program\n .command('list')\n .description('List available codemods')\n .action(() => {\n const maxNameLength = Math.max(...codemods.map(m => m.name.length));\n for (const codemod of codemods) {\n const paddedName = codemod.name.padEnd(maxNameLength, ' ');\n console.log(`${paddedName} - ${codemod.description}`);\n }\n });\n\n program.on('command:*', () => {\n console.log();\n console.log(chalk.red(`Invalid command: ${program.args.join(' ')}`));\n console.log();\n program.outputHelp();\n process.exit(1);\n });\n\n program.parse(argv);\n}\n\nprocess.on('unhandledRejection', (rejection: unknown) => {\n if (rejection instanceof Error) {\n exitWithError(rejection);\n } else {\n exitWithError(new Error(`Unknown rejection: '${rejection}'`));\n }\n});\n\nmain(process.argv).catch(exitWithError);\n"],"names":["chalk","findPaths","relativePath","platform","spawn","program"],"mappings":";;;;;;;;;;;;;AAqBO,MAAM,QAAsB,GAAA;AAAA,EACjC;AAAA,IACE,IAAM,EAAA,cAAA;AAAA,IACN,WACE,EAAA,2EAAA;AAAA,GACJ;AAAA,EACA;AAAA,IACE,IAAM,EAAA,iBAAA;AAAA,IACN,WACE,EAAA,oEAAA;AAAA,GACJ;AACF,CAAA;;;;;;;;ACdO,MAAM,oBAAoB,KAAM,CAAA;AAAA,EACrC,IAAI,IAAe,GAAA;AACjB,IAAA,OAAO,KAAK,WAAY,CAAA,IAAA,CAAA;AAAA,GAC1B;AACF,CAAA;AAEO,MAAM,sBAAsB,WAAY,CAAA;AAAA,EAG7C,WAAA,CAAY,MAAc,OAAkB,EAAA;AAAA,IAAA,IAAA,OAAA,GAAA,CAAA,GAAA,IAAA,KAAA;AAAA,MAAA,KAAA,CAAA,GAAA,IAAA,CAAA,CAAA;AAF5C,MAAS,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AAEmC,MAAA,OAAA,IAAA,CAAA;AAAA,KAAA,CAAA;AAC1C,IAAA,IAAI,OAAS,EAAA;AACX,MAAA,OAAA,CAAM,CAAY,SAAA,EAAA,OAAO,CAAsB,mBAAA,EAAA,IAAI,CAAE,CAAA,CAAA,CAAA;AAAA,KAChD,MAAA;AACL,MAAM,OAAA,CAAA,CAAA,uBAAA,EAA0B,IAAI,CAAE,CAAA,CAAA,CAAA;AAAA,KACxC;AACA,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA,CAAA;AAAA,GACd;AACF,CAAA;AAEO,SAAS,cAAc,KAAqB,EAAA;AACjD,EAAA,IAAI,iBAAiB,aAAe,EAAA;AAClC,IAAA,OAAA,CAAQ,OAAO,KAAM,CAAA,CAAA;AAAA,EAAKA,yBA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CAAE,CAAC,CAAA,CAAA;AACnE,IAAA,OAAA,CAAQ,GAAI,EAAA,CAAA;AACZ,IAAAA,iBAAA,CAAQ,UAAW,EAAA,CAAA;AACnB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAA;AAAA,GACf,CAAA,CAAA;AAED,EAAAA,iBAAA,CAAQ,MAAM,IAAI,CAAA,CAAA;AACpB,CAAA;AAEA,OAAQ,CAAA,EAAA,CAAG,oBAAsB,EAAA,CAAC,SAAuB,KAAA;AACvD,EAAA,IAAI,qBAAqB,KAAO,EAAA;AAC9B,IAAA,aAAA,CAAc,SAAS,CAAA,CAAA;AAAA,GAClB,MAAA;AACL,IAAA,aAAA,CAAc,IAAI,KAAA,CAAM,CAAuB,oBAAA,EAAA,SAAS,GAAG,CAAC,CAAA,CAAA;AAAA,GAC9D;AACF,CAAC,CAAA,CAAA;AAED,IAAA,CAAK,OAAQ,CAAA,IAAI,CAAE,CAAA,KAAA,CAAM,aAAa,CAAA;;"}
package/package.json CHANGED
@@ -1,58 +1,57 @@
1
1
  {
2
2
  "name": "@backstage/codemods",
3
+ "version": "0.1.48",
3
4
  "description": "A collection of codemods for Backstage projects",
4
- "version": "0.1.46",
5
+ "backstage": {
6
+ "role": "cli"
7
+ },
5
8
  "publishConfig": {
6
9
  "access": "public",
7
10
  "main": "dist/index.cjs.js"
8
11
  },
9
- "backstage": {
10
- "role": "cli"
11
- },
12
+ "keywords": [
13
+ "backstage"
14
+ ],
12
15
  "homepage": "https://backstage.io",
13
16
  "repository": {
14
17
  "type": "git",
15
18
  "url": "https://github.com/backstage/backstage",
16
19
  "directory": "packages/codemods"
17
20
  },
18
- "keywords": [
19
- "backstage"
20
- ],
21
21
  "license": "Apache-2.0",
22
22
  "main": "dist/index.cjs.js",
23
+ "bin": {
24
+ "backstage-codemods": "bin/backstage-codemods"
25
+ },
26
+ "files": [
27
+ "bin",
28
+ "dist",
29
+ "transforms"
30
+ ],
23
31
  "scripts": {
24
- "start": "nodemon --",
25
32
  "build": "backstage-cli package build",
33
+ "clean": "backstage-cli package clean",
26
34
  "lint": "backstage-cli package lint",
27
- "test": "backstage-cli package test",
28
35
  "prepack": "backstage-cli package prepack",
29
36
  "postpack": "backstage-cli package postpack",
30
- "clean": "backstage-cli package clean"
37
+ "start": "nodemon --",
38
+ "test": "backstage-cli package test"
31
39
  },
32
- "bin": {
33
- "backstage-codemods": "bin/backstage-codemods"
40
+ "nodemonConfig": {
41
+ "exec": "bin/backstage-codemods",
42
+ "ext": "ts",
43
+ "watch": "./src"
34
44
  },
35
45
  "dependencies": {
36
46
  "@backstage/cli-common": "^0.1.13",
37
47
  "chalk": "^4.0.0",
38
- "commander": "^9.1.0",
48
+ "commander": "^12.0.0",
39
49
  "jscodeshift": "^0.15.0",
40
50
  "jscodeshift-add-imports": "^1.0.10"
41
51
  },
42
52
  "devDependencies": {
43
- "@backstage/cli": "^0.23.0",
53
+ "@backstage/cli": "^0.26.0",
44
54
  "@types/jscodeshift": "^0.11.0",
45
- "@types/node": "^18.17.8",
46
- "ts-node": "^10.0.0"
47
- },
48
- "nodemonConfig": {
49
- "watch": "./src",
50
- "exec": "bin/backstage-codemods",
51
- "ext": "ts"
52
- },
53
- "files": [
54
- "bin",
55
- "dist",
56
- "transforms"
57
- ]
55
+ "@types/node": "^18.17.8"
56
+ }
58
57
  }