<commit_before>import "dart:io";
import "dart:uri";
import "dart:async";
import "dart:json" as JSON;
import "package:args/args.dart";

String fileDate(Date date) => "${date.year}${(date.month < 10) ? 0 : ""}${date.month}${(date.day < 10) ? 0 : ""}${date.day}_${(date.hour < 10) ? 0 : ""}${date.hour}${(date.minute < 10) ? 0 : ""}${date.minute}${(date.second < 10) ? 0 : ""}${date.second}";
String capitalize(String string) => "${string.substring(0,1).toUpperCase()}${string.substring(1)}";
String cleanName(String name) => name.replaceAll(new RegExp(r"(\W)"), "_");

const Map parameterType = const {
  "string": "String",
  "number": "num",
  "integer": "int",
  "boolean": "bool"
};

class Generator {
  String _data;
  Map _json;
  String _name;
  String _version;
  String _libraryName;
  String _libraryBrowserName;
  String _libraryConsoleName;
  String _libraryPubspecName;
  String _clientVersion = "0.0.3";

  Generator(this._data) {
    _json = JSON.parse(_data);
    _name = _json["name"];
    _version = _json["version"];
    _libraryName = cleanName("${_name}_${_version}_api_client");
    _libraryBrowserName = cleanName("${_name}_${_version}_api_browser");
    _libraryConsoleName = cleanName("${_name}_${_version}_api_console");
    _libraryPubspecName = cleanName("${_name}_${_version}_api");
  }

  void generateClient(String outputDirectory) {
    var folderName = "$outputDirectory/$_libraryName";
    (new Directory("$folderName/lib/src/common")).createSync(recursive: true);
    (new Directory("$folderName/lib/src/browser")).createSync(recursive: true);
    (new Directory("$folderName/lib/src/console")).createSync(recursive: true);

    (new File("$folderName/pubspec.yaml")).writeAsStringSync(_createPubspec());

    (new File("$folderName/LICENSE")).writeAsStringSync(_createLicense());

    (new File("$folderName/README.md")).writeAsStringSync(_createReadme());

    (new File("$folderName/CONTRIBUTORS")).writeAsStringSync(_createContributors());

    // Create common library files

    (new File("$folderName/lib/$_libraryName.dart")).writeAsStringSync(_createLibrary());

    (new File("$folderName/lib/src/common/client.dart")).writeAsStringSync(_createClientClass());

    (new File("$folderName/lib/src/common/schemas.dart")).writeAsStringSync(_createSchemas());

    (new File("$folderName/lib/src/common/resources.dart")).writeAsStringSync(_createResources());

    // Create browser versions of the libraries
    (new File("$folderName/lib/$_libraryBrowserName.dart")).writeAsStringSync(_createBrowserLibrary());

    (new File("$folderName/lib/src/browser/browserclient.dart")).writeAsStringSync(_createBrowserClientClass());

    (new File("$folderName/lib/src/browser/$_name.dart")).writeAsStringSync(_createBrowserMainClass());

    // Create console versions of the libraries
    (new File("$folderName/lib/$_libraryConsoleName.dart")).writeAsStringSync(_createConsoleLibrary());

    (new File("$folderName/lib/src/console/consoleclient.dart")).writeAsStringSync(_createConsoleClientClass());

    (new File("$folderName/lib/src/console/$_name.dart")).writeAsStringSync(_createConsoleMainClass());
  }

  String _createPubspec() {
    return """
name: $_libraryPubspecName
version: $_clientVersion
description: Auto-generated client library for accessing the $_name $_version API
homepage: https://github.com/dart-gde/discovery_api_dart_client_generator
authors:
- <NAME> <<EMAIL>>
- <NAME> <<EMAIL>>

dependencies:
  js: '>=0.0.14'
  google_oauth2_client: '>=0.1.0'
""";<commit_msg>bump the pub spec version<commit_after>import "dart:io";
import "dart:uri";
import "dart:async";
import "dart:json" as JSON;
import "package:args/args.dart";

String fileDate(Date date) => "${date.year}${(date.month < 10) ? 0 : ""}${date.month}${(date.day < 10) ? 0 : ""}${date.day}_${(date.hour < 10) ? 0 : ""}${date.hour}${(date.minute < 10) ? 0 : ""}${date.minute}${(date.second < 10) ? 0 : ""}${date.second}";
String capitalize(String string) => "${string.substring(0,1).toUpperCase()}${string.substring(1)}";
String cleanName(String name) => name.replaceAll(new RegExp(r"(\W)"), "_");

const Map parameterType = const {
  "string": "String",
  "number": "num",
  "integer": "int",
  "boolean": "bool"
};

class Generator {
  String _data;
  Map _json;
  String _name;
  String _version;
  String _libraryName;
  String _libraryBrowserName;
  String _libraryConsoleName;
  String _libraryPubspecName;
  String _clientVersion = "0.0.3";

  Generator(this._data) {
    _json = JSON.parse(_data);
    _name = _json["name"];
    _version = _json["version"];
    _libraryName = cleanName("${_name}_${_version}_api_client");
    _libraryBrowserName = cleanName("${_name}_${_version}_api_browser");
    _libraryConsoleName = cleanName("${_name}_${_version}_api_console");
    _libraryPubspecName = cleanName("${_name}_${_version}_api");
  }

  void generateClient(String outputDirectory) {
    var folderName = "$outputDirectory/$_libraryName";
    (new Directory("$folderName/lib/src/common")).createSync(recursive: true);
    (new Directory("$folderName/lib/src/browser")).createSync(recursive: true);
    (new Directory("$folderName/lib/src/console")).createSync(recursive: true);

    (new File("$folderName/pubspec.yaml")).writeAsStringSync(_createPubspec());

    (new File("$folderName/LICENSE")).writeAsStringSync(_createLicense());

    (new File("$folderName/README.md")).writeAsStringSync(_createReadme());

    (new File("$folderName/CONTRIBUTORS")).writeAsStringSync(_createContributors());

    // Create common library files

    (new File("$folderName/lib/$_libraryName.dart")).writeAsStringSync(_createLibrary());

    (new File("$folderName/lib/src/common/client.dart")).writeAsStringSync(_createClientClass());

    (new File("$folderName/lib/src/common/schemas.dart")).writeAsStringSync(_createSchemas());

    (new File("$folderName/lib/src/common/resources.dart")).writeAsStringSync(_createResources());

    // Create browser versions of the libraries
    (new File("$folderName/lib/$_libraryBrowserName.dart")).writeAsStringSync(_createBrowserLibrary());

    (new File("$folderName/lib/src/browser/browserclient.dart")).writeAsStringSync(_createBrowserClientClass());

    (new File("$folderName/lib/src/browser/$_name.dart")).writeAsStringSync(_createBrowserMainClass());

    // Create console versions of the libraries
    (new File("$folderName/lib/$_libraryConsoleName.dart")).writeAsStringSync(_createConsoleLibrary());

    (new File("$folderName/lib/src/console/consoleclient.dart")).writeAsStringSync(_createConsoleClientClass());

    (new File("$folderName/lib/src/console/$_name.dart")).writeAsStringSync(_createConsoleMainClass());
  }

  String _createPubspec() {
    return """
name: $_libraryPubspecName
version: $_clientVersion
description: Auto-generated client library for accessing the $_name $_version API
homepage: https://github.com/dart-gde/discovery_api_dart_client_generator
authors:
- <NAME> <<EMAIL>>
- <NAME> <<EMAIL>>

dependencies:
  js: '>=0.0.14'
  google_oauth2_client: '>=0.2.0'
""";
{'fraction_non_alphanumeric': 0.1751556310130164, 'fraction_numerical': 0.008205998868138087, 'mean_word_length': 5.829951690821256, 'pattern_counts': {'":': 8, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 2, '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': '305179', 'n_tokens_mistral': 2348, 'n_tokens_neox': 2251, 'n_words': 356}