<commit_before>const dasherize = require('ember-cli-string-utils').dasherize;

module.exports = {
  description: 'Ember CLI blueprint for initializing a new Glimmer application',

  // filesToRemove: [
  //   'app/styles/.gitkeep',
  //   'app/templates/.gitkeep',
  // ],

  locals(options) {
    let name = options.entity.name;
    let component = componentize(name);

    return { name, component };
  },

  fileMapTokens(options) {
    return {
      __component__() { return options.locals.component }
    }
  },

  afterInstall(options) {
    if (options.webComponent) {
      this._installWebComponentSupport(options);
    }
  },

  _installWebComponentSupport(options) {
    let name = options.entity.name;
    let component = componentize(name);

    this.addPackageToProject('@glimmer/web-component');
    this.insertIntoFile(
      'src/index.ts',
      "import initializeCustomElements from '@glimmer/web-component';",
      { after: "import { ComponentManager, setPropertyDidChange } from '@glimmer/component';\n" }
    ).then(() => {
      return this.insertIntoFile(
        'src/index.ts',
        `initializeCustomElements(app, ['${component}']);\n`
      );
    });
  }
};

// Component names must have at least one dash, so we prefix the component name
// if it doesn't have one. E.g.: `avatar` -> `-avatar`
function componentize(name) {<commit_msg>Return a promise from `afterInstall`<commit_after>const dasherize = require('ember-cli-string-utils').dasherize;

module.exports = {
  description: 'Ember CLI blueprint for initializing a new Glimmer application',

  // filesToRemove: [
  //   'app/styles/.gitkeep',
  //   'app/templates/.gitkeep',
  // ],

  locals(options) {
    let name = options.entity.name;
    let component = componentize(name);

    return { name, component };
  },

  fileMapTokens(options) {
    return {
      __component__() { return options.locals.component }
    }
  },

  afterInstall(options) {
    if (options.webComponent) {
      return this._installWebComponentSupport(options);
    }
  },

  _installWebComponentSupport(options) {
    let name = options.entity.name;
    let component = componentize(name);

    let addPackagePromise = this.addPackageToProject('@glimmer/web-component');
    let indexTSPromise = this.insertIntoFile(
      'src/index.ts',
      "import initializeCustomElements from '@glimmer/web-component';",
      { after: "import { ComponentManager, setPropertyDidChange } from '@glimmer/component';\n" }
    ).then(() => {
      return this.insertIntoFile(
        'src/index.ts',
        `initializeCustomElements(app, ['${component}']);\n`
      );
    });

    return Promise.all([
      addPackagePromise,
      indexTSPromise
    ]);
  }
};

// Component names must have at least one dash, so we prefix the component name
// if it doesn't have one. E.g.: `avatar` -> `-avatar`
function componentize(name) {
{'fraction_non_alphanumeric': 0.13870632998962296, 'fraction_numerical': 0.0, 'mean_word_length': 3.173160173160173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3294660', 'n_tokens_mistral': 881, 'n_tokens_neox': 877, 'n_words': 185}