Skip to content

Commit

Permalink
feat(very_good_core): add LICENSE and copyright header (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Feb 4, 2021
1 parent 2486b29 commit 58a0ac2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 12 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Very Good Ventures

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions templates/very_good_core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Very Good Ventures

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 24 additions & 12 deletions tool/generator/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ final _targetPath = path.join(
'__brick__',
);

const copyrightHeader = '''
// Copyright (c) 2021, Very Good Ventures
// https://verygood.ventures
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
''';

void main() async {
// Remove Previously Generated Files
final targetDir = Directory(_targetPath);
Expand All @@ -27,6 +36,11 @@ void main() async {
var file = _;

try {
if (path.extension(file.path) == '.dart') {
final contents = await file.readAsString();
file = await file.writeAsString('$copyrightHeader\n$contents');
}

final contents = await file.readAsString();
file = await file.writeAsString(
contents
Expand All @@ -37,19 +51,17 @@ void main() async {
'{{#titleCase}}{{project_name}}{{/titleCase}}',
),
);
final fileSegments = file.path.split('/').sublist(3);
if (fileSegments.contains('very_good_core')) {
final newPathSegment = fileSegments
.join('/')
.replaceAll('very_good_core', '{{project_name}}');
final newPath = path.join(_targetPath, newPathSegment);
File(newPath).createSync(recursive: true);
file.renameSync(newPath);
Directory(file.parent.path).deleteSync(recursive: true);
}
} catch (_) {}

final fileSegments = file.path.split('/').sublist(3);
if (fileSegments.contains('very_good_core')) {
final newPathSegment = fileSegments.join('/').replaceAll(
'very_good_core',
'{{project_name}}',
);
final newPath = path.join(_targetPath, newPathSegment);
File(newPath).createSync(recursive: true);
file.renameSync(newPath);
Directory(file.parent.path).deleteSync(recursive: true);
}
}),
);
}
Expand Down

0 comments on commit 58a0ac2

Please sign in to comment.