Skip to content
CLI & codemod scripts for upgrading to CanJS 3, 4 and 5
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
build
src
test
.babelrc
.editorconfig
.gitignore
.jshintignore
.jshintrc
.npmignore
.npmrc
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
config.json
index.js
package.json
yarn.lock

README.md

can-migrate

npm version Build Status Greenkeeper badge

CLI & codemod scripts for upgrading to CanJS 3.

Usage

Check out the Using Codemods guide on canjs.com for an overview of this project, how to install can-migrate, how to use the CLI, and recommendations for how to migrate your app.

transforms.json

There is one entry in the array per type of template/test required to generate the transforms. The current groups of transforms are:

  • Component Rename: rename parts of a component
  • can.extend: swap out extend for assign or deep-assign
  • can-data: swap out .data() for domData
  • Replace imports/requires: Replace existing import/require statements and replace any references in the code
  • Replace can.: Replace can. methods and add the corresponding import/require
[
  {
    "copy": [ // Copy these files from src
      {
        "input": "...", // Source filename
        "output: "...", // Destination filename
        "type": "fixture|test|transform" // Type of copy determines where the destination file ends up (more on that below)
      }
    ],
    "generate": [ // Generate output from the template in src using "transforms
      {
        "template": "...", // Source filename
        "outputPath: "...", // Destination filename
        "type": "fixture|test|transform" // Type of copy determines where the destination file ends up (more on that below)
      }
    ],
    "transforms": [
      {
        "shortName": "component", // Short name of the transform for debugging and template filename generation
        "oldSourceValues": [ // List of ways this component could be imported/required. Used to replace these with newer component import
          "can/component/",
          "can/component/component",
          "can/component/component.js"
        ],
        "newSourceValue": "can-component", // The new value of the import/require
        "exampleLocalName": "MyComponent" // The example local name to include in generate documentation
        "oldObjectName": "can", // Object name to look for
        "oldPropertyName": "addEvent", // Property name to look for
        "newPropertyName": addEventListener, // What should replace the object.property (false for nothing, could be a complex replacement like mutate.appendChild)
        "sourceValue": "can-construct" // Key to look up the configurable naming in config.json
      }
    ]
  }
]

Types

  • test: Copied to lib, file is added to test/test.js.
  • fixture : Copied to test/fixtures
  • transform: Copied to lib/transforms
You can’t perform that action at this time.