How to use the @ngrx/store/schematics-core.InsertChange function in @ngrx/store

To help you get started, we’ve selected a few @ngrx/store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngrx / store-builds / migrations / 8_0_0-rc / index.js View on Github external
const runtimeChecks = `runtimeChecks: { strictStateImmutability: true, strictActionImmutability: true }`;
            // covers StoreModule.forRoot(ROOT_REDUCERS)
            if (node.arguments.length === 1) {
                changes.push(new schematics_core_1.InsertChange(sourceFile.fileName, node.arguments[0].getEnd(), `, { ${runtimeChecks}}`));
            }
            else if (node.arguments.length === 2) {
                const storeConfig = node.arguments[1];
                if (ts.isObjectLiteralExpression(storeConfig)) {
                    // covers StoreModule.forRoot(ROOT_REDUCERS, {})
                    if (storeConfig.properties.length === 0) {
                        changes.push(new schematics_core_1.InsertChange(sourceFile.fileName, storeConfig.getEnd() - 1, `${runtimeChecks} `));
                    }
                    else {
                        // covers StoreModule.forRoot(ROOT_REDUCERS, { metaReducers })
                        const lastProperty = storeConfig.properties[storeConfig.properties.length - 1];
                        changes.push(new schematics_core_1.InsertChange(sourceFile.fileName, lastProperty.getEnd(), `, ${runtimeChecks}`));
                    }
                }
            }
        }
    }
github ngrx / platform / modules / store / migrations / 8_0_0-rc / index.ts View on Github external
// covers StoreModule.forRoot(ROOT_REDUCERS)
    if (node.arguments.length === 1) {
      changes.push(
        new InsertChange(
          sourceFile.fileName,
          node.arguments[0].getEnd(),
          `, { ${runtimeChecks}}`
        )
      );
    } else if (node.arguments.length === 2) {
      const storeConfig = node.arguments[1];
      if (ts.isObjectLiteralExpression(storeConfig)) {
        // covers StoreModule.forRoot(ROOT_REDUCERS, {})
        if (storeConfig.properties.length === 0) {
          changes.push(
            new InsertChange(
              sourceFile.fileName,
              storeConfig.getEnd() - 1,
              `${runtimeChecks} `
            )
          );
        } else {
          // covers StoreModule.forRoot(ROOT_REDUCERS, { metaReducers })
          const lastProperty =
            storeConfig.properties[storeConfig.properties.length - 1];

          changes.push(
            new InsertChange(
              sourceFile.fileName,
              lastProperty.getEnd(),
              `, ${runtimeChecks}`
            )
github ngrx / store-builds / migrations / 8_0_0-rc / index.js View on Github external
if (!(ts.isPropertyAccessExpression(expression) &&
                expression.expression.getText(sourceFile) === 'StoreModule' &&
                expression.name.getText(sourceFile) === 'forRoot')) {
                return;
            }
            const runtimeChecks = `runtimeChecks: { strictStateImmutability: true, strictActionImmutability: true }`;
            // covers StoreModule.forRoot(ROOT_REDUCERS)
            if (node.arguments.length === 1) {
                changes.push(new schematics_core_1.InsertChange(sourceFile.fileName, node.arguments[0].getEnd(), `, { ${runtimeChecks}}`));
            }
            else if (node.arguments.length === 2) {
                const storeConfig = node.arguments[1];
                if (ts.isObjectLiteralExpression(storeConfig)) {
                    // covers StoreModule.forRoot(ROOT_REDUCERS, {})
                    if (storeConfig.properties.length === 0) {
                        changes.push(new schematics_core_1.InsertChange(sourceFile.fileName, storeConfig.getEnd() - 1, `${runtimeChecks} `));
                    }
                    else {
                        // covers StoreModule.forRoot(ROOT_REDUCERS, { metaReducers })
                        const lastProperty = storeConfig.properties[storeConfig.properties.length - 1];
                        changes.push(new schematics_core_1.InsertChange(sourceFile.fileName, lastProperty.getEnd(), `, ${runtimeChecks}`));
                    }
                }
            }
        }
    }
github ngrx / platform / modules / store / migrations / 8_0_0-rc / index.ts View on Github external
// covers StoreModule.forRoot(ROOT_REDUCERS, {})
        if (storeConfig.properties.length === 0) {
          changes.push(
            new InsertChange(
              sourceFile.fileName,
              storeConfig.getEnd() - 1,
              `${runtimeChecks} `
            )
          );
        } else {
          // covers StoreModule.forRoot(ROOT_REDUCERS, { metaReducers })
          const lastProperty =
            storeConfig.properties[storeConfig.properties.length - 1];

          changes.push(
            new InsertChange(
              sourceFile.fileName,
              lastProperty.getEnd(),
              `, ${runtimeChecks}`
            )
          );
        }
      }
    }
  }
}
github ngrx / platform / modules / store / migrations / 8_0_0-rc / index.ts View on Github external
const elements = node.elements.map(elem => elem.getText(sourceFile));
    const elementsWithoutStoreFreeze = elements.filter(
      elemText => elemText !== 'storeFreeze'
    );

    if (elements.length !== elementsWithoutStoreFreeze.length) {
      changes.push(
        new RemoveChange(
          sourceFile.fileName,
          node.getStart(sourceFile),
          node.getEnd()
        )
      );
      changes.push(
        new InsertChange(
          sourceFile.fileName,
          node.getStart(sourceFile),
          `[${elementsWithoutStoreFreeze.join(', ')}]`
        )
      );
    }
  }
}
github ngrx / store-builds / migrations / 8_0_0-rc / index.js View on Github external
function crawl(node) {
            ts.forEachChild(node, crawl);
            if (!ts.isArrayLiteralExpression(node))
                return;
            const elements = node.elements.map(elem => elem.getText(sourceFile));
            const elementsWithoutStoreFreeze = elements.filter(elemText => elemText !== 'storeFreeze');
            if (elements.length !== elementsWithoutStoreFreeze.length) {
                changes.push(new schematics_core_1.RemoveChange(sourceFile.fileName, node.getStart(sourceFile), node.getEnd()));
                changes.push(new schematics_core_1.InsertChange(sourceFile.fileName, node.getStart(sourceFile), `[${elementsWithoutStoreFreeze.join(', ')}]`));
            }
        }
    }