@backstage/codemods 0.1.52 → 0.1.53-next.1

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,20 @@
1
1
  # @backstage/codemods
2
2
 
3
+ ## 0.1.53-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 688f070: Updated to use new utilities from `@backstage/cli-common`.
8
+ - Updated dependencies
9
+ - @backstage/cli-common@0.1.16-next.1
10
+
11
+ ## 0.1.53-next.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+ - @backstage/cli-common@0.1.16-next.0
17
+
3
18
  ## 0.1.52
4
19
 
5
20
  ### Patch Changes
@@ -1,10 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var path = require('path');
4
- var child_process = require('child_process');
5
4
  var cliCommon = require('@backstage/cli-common');
6
5
  var os = require('os');
7
- var errors = require('./errors.cjs.js');
8
6
 
9
7
  const paths = cliCommon.findPaths(__dirname);
10
8
  function createCodemodAction(name) {
@@ -29,37 +27,22 @@ function createCodemodAction(name) {
29
27
  args.push(".");
30
28
  }
31
29
  console.log(`Running jscodeshift with these arguments: ${args.join(" ")}`);
32
- let command;
30
+ let commandArgs;
33
31
  if (os.platform() === "win32") {
34
- command = "jscodeshift";
32
+ commandArgs = ["jscodeshift", ...args];
35
33
  } else {
36
- command = process.argv0;
37
- args.unshift(require.resolve(".bin/jscodeshift"));
34
+ commandArgs = [
35
+ process.argv0,
36
+ require.resolve(".bin/jscodeshift"),
37
+ ...args
38
+ ];
38
39
  }
39
- const child = child_process.spawn(command, args, {
40
- stdio: "inherit",
41
- shell: true,
40
+ await cliCommon.run(commandArgs, {
42
41
  env: {
43
42
  ...process.env,
44
43
  FORCE_COLOR: "true"
45
44
  }
46
- });
47
- if (typeof child.exitCode === "number") {
48
- if (child.exitCode) {
49
- throw new errors.ExitCodeError(child.exitCode, name);
50
- }
51
- return;
52
- }
53
- await new Promise((resolve, reject) => {
54
- child.once("error", (error) => reject(error));
55
- child.once("exit", (code) => {
56
- if (code) {
57
- reject(new errors.ExitCodeError(code, name));
58
- } else {
59
- resolve();
60
- }
61
- });
62
- });
45
+ }).waitForExit();
63
46
  };
64
47
  }
65
48
 
@@ -1 +1 @@
1
- {"version":3,"file":"action.cjs.js","sources":["../src/action.ts"],"sourcesContent":["/*\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"],"names":["findPaths","relativePath","platform","spawn","ExitCodeError"],"mappings":";;;;;;;;AAwBA,MAAM,KAAA,GAAQA,oBAAU,SAAS,CAAA;AAE1B,SAAS,oBAAoB,IAAc,EAAA;AAChD,EAAO,OAAA,OAAO,MAAgB,IAAuB,KAAA;AACnD,IAAA,MAAM,aAAgB,GAAAC,aAAA;AAAA,MACpB,QAAQ,GAAI,EAAA;AAAA,MACZ,KAAM,CAAA,UAAA,CAAW,YAAc,EAAA,CAAA,EAAG,IAAI,CAAK,GAAA,CAAA;AAAA,KAC7C;AAEA,IAAA,MAAM,IAAO,GAAA;AAAA,MACX,cAAA;AAAA,MACA,4BAAA;AAAA,MACA,aAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,IAAI,KAAK,GAAK,EAAA;AACZ,MAAA,IAAA,CAAK,KAAK,OAAO,CAAA;AAAA;AAGnB,IAAA,IAAI,KAAK,MAAQ,EAAA;AACf,MAAK,IAAA,CAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,KACZ,MAAA;AACL,MAAA,IAAA,CAAK,KAAK,GAAG,CAAA;AAAA;AAGf,IAAA,OAAA,CAAQ,IAAI,CAA6C,0CAAA,EAAA,IAAA,CAAK,IAAK,CAAA,GAAG,CAAC,CAAE,CAAA,CAAA;AAEzE,IAAI,IAAA,OAAA;AACJ,IAAI,IAAAC,WAAA,OAAe,OAAS,EAAA;AAC1B,MAAU,OAAA,GAAA,aAAA;AAAA,KACL,MAAA;AAIL,MAAA,OAAA,GAAU,OAAQ,CAAA,KAAA;AAClB,MAAA,IAAA,CAAK,OAAQ,CAAA,OAAA,CAAQ,OAAQ,CAAA,kBAAkB,CAAC,CAAA;AAAA;AAGlD,IAAM,MAAA,KAAA,GAAQC,mBAAM,CAAA,OAAA,EAAS,IAAM,EAAA;AAAA,MACjC,KAAO,EAAA,SAAA;AAAA,MACP,KAAO,EAAA,IAAA;AAAA,MACP,GAAK,EAAA;AAAA,QACH,GAAG,OAAQ,CAAA,GAAA;AAAA,QACX,WAAa,EAAA;AAAA;AACf,KACD,CAAA;AAED,IAAI,IAAA,OAAO,KAAM,CAAA,QAAA,KAAa,QAAU,EAAA;AACtC,MAAA,IAAI,MAAM,QAAU,EAAA;AAClB,QAAA,MAAM,IAAIC,oBAAA,CAAc,KAAM,CAAA,QAAA,EAAU,IAAI,CAAA;AAAA;AAE9C,MAAA;AAAA;AAGF,IAAA,MAAM,IAAI,OAAA,CAAc,CAAC,OAAA,EAAS,MAAW,KAAA;AAC3C,MAAA,KAAA,CAAM,IAAK,CAAA,OAAA,EAAS,CAAS,KAAA,KAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AAC1C,MAAM,KAAA,CAAA,IAAA,CAAK,QAAQ,CAAQ,IAAA,KAAA;AACzB,QAAA,IAAI,IAAM,EAAA;AACR,UAAA,MAAA,CAAO,IAAIA,oBAAA,CAAc,IAAM,EAAA,IAAI,CAAC,CAAA;AAAA,SAC/B,MAAA;AACL,UAAQ,OAAA,EAAA;AAAA;AACV,OACD,CAAA;AAAA,KACF,CAAA;AAAA,GACH;AACF;;;;"}
1
+ {"version":3,"file":"action.cjs.js","sources":["../src/action.ts"],"sourcesContent":["/*\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 { OptionValues } from 'commander';\nimport { findPaths, run } from '@backstage/cli-common';\nimport { platform } from 'os';\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 commandArgs: string[];\n if (platform() === 'win32') {\n commandArgs = ['jscodeshift', ...args];\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 commandArgs = [\n process.argv0,\n require.resolve('.bin/jscodeshift'),\n ...args,\n ];\n }\n\n await run(commandArgs, {\n env: {\n ...process.env,\n FORCE_COLOR: 'true',\n },\n }).waitForExit();\n };\n}\n"],"names":["findPaths","relativePath","platform","run"],"mappings":";;;;;;AAsBA,MAAM,KAAA,GAAQA,oBAAU,SAAS,CAAA;AAE1B,SAAS,oBAAoB,IAAA,EAAc;AAChD,EAAA,OAAO,OAAO,MAAgB,IAAA,KAAuB;AACnD,IAAA,MAAM,aAAA,GAAgBC,aAAA;AAAA,MACpB,QAAQ,GAAA,EAAI;AAAA,MACZ,KAAA,CAAM,UAAA,CAAW,YAAA,EAAc,CAAA,EAAG,IAAI,CAAA,GAAA,CAAK;AAAA,KAC7C;AAEA,IAAA,MAAM,IAAA,GAAO;AAAA,MACX,cAAA;AAAA,MACA,4BAAA;AAAA,MACA,aAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,IAAA,CAAK,KAAK,OAAO,CAAA;AAAA,IACnB;AAEA,IAAA,IAAI,KAAK,MAAA,EAAQ;AACf,MAAA,IAAA,CAAK,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,IACnB,CAAA,MAAO;AACL,MAAA,IAAA,CAAK,KAAK,GAAG,CAAA;AAAA,IACf;AAEA,IAAA,OAAA,CAAQ,IAAI,CAAA,0CAAA,EAA6C,IAAA,CAAK,IAAA,CAAK,GAAG,CAAC,CAAA,CAAE,CAAA;AAEzE,IAAA,IAAI,WAAA;AACJ,IAAA,IAAIC,WAAA,OAAe,OAAA,EAAS;AAC1B,MAAA,WAAA,GAAc,CAAC,aAAA,EAAe,GAAG,IAAI,CAAA;AAAA,IACvC,CAAA,MAAO;AAIL,MAAA,WAAA,GAAc;AAAA,QACZ,OAAA,CAAQ,KAAA;AAAA,QACR,OAAA,CAAQ,QAAQ,kBAAkB,CAAA;AAAA,QAClC,GAAG;AAAA,OACL;AAAA,IACF;AAEA,IAAA,MAAMC,cAAI,WAAA,EAAa;AAAA,MACrB,GAAA,EAAK;AAAA,QACH,GAAG,OAAA,CAAQ,GAAA;AAAA,QACX,WAAA,EAAa;AAAA;AACf,KACD,EAAE,WAAA,EAAY;AAAA,EACjB,CAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"codemods.cjs.js","sources":["../src/codemods.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"],"names":[],"mappings":";;AAqBO,MAAM,QAAsB,GAAA;AAAA,EACjC;AAAA,IACE,IAAM,EAAA,cAAA;AAAA,IACN,WACE,EAAA;AAAA,GACJ;AAAA,EACA;AAAA,IACE,IAAM,EAAA,iBAAA;AAAA,IACN,WACE,EAAA;AAAA;AAEN;;;;"}
1
+ {"version":3,"file":"codemods.cjs.js","sources":["../src/codemods.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"],"names":[],"mappings":";;AAqBO,MAAM,QAAA,GAAsB;AAAA,EACjC;AAAA,IACE,IAAA,EAAM,cAAA;AAAA,IACN,WAAA,EACE;AAAA,GACJ;AAAA,EACA;AAAA,IACE,IAAA,EAAM,iBAAA;AAAA,IACN,WAAA,EACE;AAAA;AAEN;;;;"}
@@ -1,29 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var chalk = require('chalk');
4
+ var cliCommon = require('@backstage/cli-common');
4
5
 
5
6
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
7
 
7
8
  var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
8
9
 
9
- class CustomError extends Error {
10
- get name() {
11
- return this.constructor.name;
12
- }
13
- }
14
- class ExitCodeError extends CustomError {
15
- code;
16
- constructor(code, command) {
17
- if (command) {
18
- super(`Command '${command}' exited with code ${code}`);
19
- } else {
20
- super(`Child exited with code ${code}`);
21
- }
22
- this.code = code;
23
- }
24
- }
25
10
  function exitWithError(error) {
26
- if (error instanceof ExitCodeError) {
11
+ if (error instanceof cliCommon.ExitCodeError) {
27
12
  process.stderr.write(`
28
13
  ${chalk__default.default.red(error.message)}
29
14
 
@@ -38,7 +23,5 @@ ${chalk__default.default.red(`${error}`)}
38
23
  }
39
24
  }
40
25
 
41
- exports.CustomError = CustomError;
42
- exports.ExitCodeError = ExitCodeError;
43
26
  exports.exitWithError = exitWithError;
44
27
  //# sourceMappingURL=errors.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs.js","sources":["../src/errors.ts"],"sourcesContent":["/*\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"],"names":["chalk"],"mappings":";;;;;;;;AAkBO,MAAM,oBAAoB,KAAM,CAAA;AAAA,EACrC,IAAI,IAAe,GAAA;AACjB,IAAA,OAAO,KAAK,WAAY,CAAA,IAAA;AAAA;AAE5B;AAEO,MAAM,sBAAsB,WAAY,CAAA;AAAA,EACpC,IAAA;AAAA,EAET,WAAA,CAAY,MAAc,OAAkB,EAAA;AAC1C,IAAA,IAAI,OAAS,EAAA;AACX,MAAA,KAAA,CAAM,CAAY,SAAA,EAAA,OAAO,CAAsB,mBAAA,EAAA,IAAI,CAAE,CAAA,CAAA;AAAA,KAChD,MAAA;AACL,MAAM,KAAA,CAAA,CAAA,uBAAA,EAA0B,IAAI,CAAE,CAAA,CAAA;AAAA;AAExC,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA;AAAA;AAEhB;AAEO,SAAS,cAAc,KAAqB,EAAA;AACjD,EAAA,IAAI,iBAAiB,aAAe,EAAA;AAClC,IAAA,OAAA,CAAQ,OAAO,KAAM,CAAA;AAAA,EAAKA,sBAAM,CAAA,GAAA,CAAI,KAAM,CAAA,OAAO,CAAC;;AAAA,CAAM,CAAA;AACxD,IAAQ,OAAA,CAAA,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,GAClB,MAAA;AACL,IAAA,OAAA,CAAQ,OAAO,KAAM,CAAA;AAAA,EAAKA,sBAAM,CAAA,GAAA,CAAI,CAAG,EAAA,KAAK,EAAE,CAAC;;AAAA,CAAM,CAAA;AACrD,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB;;;;;;"}
1
+ {"version":3,"file":"errors.cjs.js","sources":["../src/errors.ts"],"sourcesContent":["/*\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';\nimport { ExitCodeError } from '@backstage/cli-common';\n\nexport class CustomError extends Error {\n get name(): string {\n return this.constructor.name;\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"],"names":["ExitCodeError","chalk"],"mappings":";;;;;;;;;AAyBO,SAAS,cAAc,KAAA,EAAqB;AACjD,EAAA,IAAI,iBAAiBA,uBAAA,EAAe;AAClC,IAAA,OAAA,CAAQ,OAAO,KAAA,CAAM;AAAA,EAAKC,sBAAA,CAAM,GAAA,CAAI,KAAA,CAAM,OAAO,CAAC;;AAAA,CAAM,CAAA;AACxD,IAAA,OAAA,CAAQ,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,EACzB,CAAA,MAAO;AACL,IAAA,OAAA,CAAQ,OAAO,KAAA,CAAM;AAAA,EAAKA,sBAAA,CAAM,GAAA,CAAI,CAAA,EAAG,KAAK,EAAE,CAAC;;AAAA,CAAM,CAAA;AACrD,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/index.ts"],"sourcesContent":["/*\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":["program","version","codemods","createCodemodAction","chalk","exitWithError"],"mappings":";;;;;;;;;;;;;AA6BA,eAAe,KAAK,IAAgB,EAAA;AAClC,EAAAA,iBAAA,CAAQ,IAAK,CAAA,oBAAoB,CAAE,CAAA,OAAA,CAAQC,gBAAO,CAAA;AAElD,EAAA,MAAM,YAAe,GAAAD,iBAAA,CAClB,OAAQ,CAAA,kCAAkC,CAC1C,CAAA,WAAA;AAAA,IACC;AAAA,GACF;AAEF,EAAA,KAAA,MAAW,WAAWE,iBAAU,EAAA;AAC9B,IAAA,YAAA,CACG,QAAQ,CAAG,EAAA,OAAA,CAAQ,IAAI,CAAmB,iBAAA,CAAA,CAAA,CAC1C,YAAY,OAAQ,CAAA,WAAW,CAC/B,CAAA,MAAA,CAAO,aAAa,sCAAsC,CAAA,CAC1D,OAAOC,0BAAoB,CAAA,OAAA,CAAQ,IAAI,CAAC,CAAA;AAAA;AAG7C,EAAAH,iBAAA,CACG,QAAQ,MAAM,CAAA,CACd,YAAY,yBAAyB,CAAA,CACrC,OAAO,MAAM;AACZ,IAAM,MAAA,aAAA,GAAgB,IAAK,CAAA,GAAA,CAAI,GAAGE,iBAAA,CAAS,IAAI,CAAK,CAAA,KAAA,CAAA,CAAE,IAAK,CAAA,MAAM,CAAC,CAAA;AAClE,IAAA,KAAA,MAAW,WAAWA,iBAAU,EAAA;AAC9B,MAAA,MAAM,UAAa,GAAA,OAAA,CAAQ,IAAK,CAAA,MAAA,CAAO,eAAe,GAAG,CAAA;AACzD,MAAA,OAAA,CAAQ,IAAI,CAAG,EAAA,UAAU,CAAM,GAAA,EAAA,OAAA,CAAQ,WAAW,CAAE,CAAA,CAAA;AAAA;AACtD,GACD,CAAA;AAEH,EAAQF,iBAAA,CAAA,EAAA,CAAG,aAAa,MAAM;AAC5B,IAAA,OAAA,CAAQ,GAAI,EAAA;AACZ,IAAQ,OAAA,CAAA,GAAA,CAAII,sBAAM,CAAA,GAAA,CAAI,CAAoB,iBAAA,EAAAJ,iBAAA,CAAQ,KAAK,IAAK,CAAA,GAAG,CAAC,CAAA,CAAE,CAAC,CAAA;AACnE,IAAA,OAAA,CAAQ,GAAI,EAAA;AACZ,IAAAA,iBAAA,CAAQ,UAAW,EAAA;AACnB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,GACf,CAAA;AAED,EAAAA,iBAAA,CAAQ,MAAM,IAAI,CAAA;AACpB;AAEA,OAAQ,CAAA,EAAA,CAAG,oBAAsB,EAAA,CAAC,SAAuB,KAAA;AACvD,EAAA,IAAI,qBAAqB,KAAO,EAAA;AAC9B,IAAAK,oBAAA,CAAc,SAAS,CAAA;AAAA,GAClB,MAAA;AACL,IAAAA,oBAAA,CAAc,IAAI,KAAA,CAAM,CAAuB,oBAAA,EAAA,SAAS,GAAG,CAAC,CAAA;AAAA;AAEhE,CAAC,CAAA;AAED,IAAA,CAAK,OAAQ,CAAA,IAAI,CAAE,CAAA,KAAA,CAAMA,oBAAa,CAAA;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/index.ts"],"sourcesContent":["/*\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":["program","version","codemods","createCodemodAction","chalk","exitWithError"],"mappings":";;;;;;;;;;;;;AA6BA,eAAe,KAAK,IAAA,EAAgB;AAClC,EAAAA,iBAAA,CAAQ,IAAA,CAAK,oBAAoB,CAAA,CAAE,OAAA,CAAQC,gBAAO,CAAA;AAElD,EAAA,MAAM,YAAA,GAAeD,iBAAA,CAClB,OAAA,CAAQ,kCAAkC,CAAA,CAC1C,WAAA;AAAA,IACC;AAAA,GACF;AAEF,EAAA,KAAA,MAAW,WAAWE,iBAAA,EAAU;AAC9B,IAAA,YAAA,CACG,QAAQ,CAAA,EAAG,OAAA,CAAQ,IAAI,CAAA,iBAAA,CAAmB,CAAA,CAC1C,YAAY,OAAA,CAAQ,WAAW,CAAA,CAC/B,MAAA,CAAO,aAAa,sCAAsC,CAAA,CAC1D,OAAOC,0BAAA,CAAoB,OAAA,CAAQ,IAAI,CAAC,CAAA;AAAA,EAC7C;AAEA,EAAAH,iBAAA,CACG,QAAQ,MAAM,CAAA,CACd,YAAY,yBAAyB,CAAA,CACrC,OAAO,MAAM;AACZ,IAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,GAAA,CAAI,GAAGE,iBAAA,CAAS,IAAI,CAAA,CAAA,KAAK,CAAA,CAAE,IAAA,CAAK,MAAM,CAAC,CAAA;AAClE,IAAA,KAAA,MAAW,WAAWA,iBAAA,EAAU;AAC9B,MAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,eAAe,GAAG,CAAA;AACzD,MAAA,OAAA,CAAQ,IAAI,CAAA,EAAG,UAAU,CAAA,GAAA,EAAM,OAAA,CAAQ,WAAW,CAAA,CAAE,CAAA;AAAA,IACtD;AAAA,EACF,CAAC,CAAA;AAEH,EAAAF,iBAAA,CAAQ,EAAA,CAAG,aAAa,MAAM;AAC5B,IAAA,OAAA,CAAQ,GAAA,EAAI;AACZ,IAAA,OAAA,CAAQ,GAAA,CAAII,sBAAA,CAAM,GAAA,CAAI,CAAA,iBAAA,EAAoBJ,iBAAA,CAAQ,KAAK,IAAA,CAAK,GAAG,CAAC,CAAA,CAAE,CAAC,CAAA;AACnE,IAAA,OAAA,CAAQ,GAAA,EAAI;AACZ,IAAAA,iBAAA,CAAQ,UAAA,EAAW;AACnB,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB,CAAC,CAAA;AAED,EAAAA,iBAAA,CAAQ,MAAM,IAAI,CAAA;AACpB;AAEA,OAAA,CAAQ,EAAA,CAAG,oBAAA,EAAsB,CAAC,SAAA,KAAuB;AACvD,EAAA,IAAI,qBAAqB,KAAA,EAAO;AAC9B,IAAAK,oBAAA,CAAc,SAAS,CAAA;AAAA,EACzB,CAAA,MAAO;AACL,IAAAA,oBAAA,CAAc,IAAI,KAAA,CAAM,CAAA,oBAAA,EAAuB,SAAS,GAAG,CAAC,CAAA;AAAA,EAC9D;AACF,CAAC,CAAA;AAED,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA,CAAE,KAAA,CAAMA,oBAAa,CAAA;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.1.52";
3
+ var version = "0.1.53-next.1";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/codemods",
3
- "version": "0.1.52",
3
+ "version": "0.1.53-next.1",
4
4
  "description": "A collection of codemods for Backstage projects",
5
5
  "backstage": {
6
6
  "role": "cli"
@@ -43,14 +43,14 @@
43
43
  "watch": "./src"
44
44
  },
45
45
  "dependencies": {
46
- "@backstage/cli-common": "^0.1.15",
46
+ "@backstage/cli-common": "0.1.16-next.1",
47
47
  "chalk": "^4.0.0",
48
48
  "commander": "^12.0.0",
49
49
  "jscodeshift": "^0.16.0",
50
50
  "jscodeshift-add-imports": "^1.0.10"
51
51
  },
52
52
  "devDependencies": {
53
- "@backstage/cli": "^0.29.0",
53
+ "@backstage/cli": "0.34.6-next.1",
54
54
  "@types/jscodeshift": "^0.12.0",
55
55
  "@types/node": "^20.16.0"
56
56
  }