diff --git a/app/lib/tool/test_profile/import_source.dart b/app/lib/tool/test_profile/import_source.dart index ca9155242e..dc01df0084 100644 --- a/app/lib/tool/test_profile/import_source.dart +++ b/app/lib/tool/test_profile/import_source.dart @@ -14,12 +14,15 @@ import 'package:meta/meta.dart'; import 'package:path/path.dart' as p; import 'package:tar/tar.dart'; -import '../../fake/backend/fake_pana_runner.dart'; import '../../shared/urls.dart' as urls; import 'models.dart'; import 'resolver.dart' as resolver; +final _markdownSamples = + File(p.join('lib', 'tool', 'test_profile', 'markdown_samples.md')) + .readAsStringSync(); + /// Utility class for resolving and getting data for profiles. class ImportSource { final _client = Client(); @@ -103,17 +106,15 @@ class ImportSource { TestArchiveTemplate? template, ) async { final key = '$package/$version'; - final hasher = createHasher(key); if (_archives.containsKey(key)) { return _archives[key]!; } final archive = ArchiveBuilder(); - final hasHomepage = !version.contains('nohomepage'); - final hasRepository = hasher('hasRepository', max: 20) > 0; - final isLegacy = version.contains('legacy'); - final sdkConstraint = - template?.sdkConstraint ?? (isLegacy ? '>=1.12.0 <2.0.0' : '^3.0.0'); + final homepage = template?.homepage ?? 'https://$package.example.com/'; + final repository = + template?.repository ?? 'https://github.com/example/$package'; + final sdkConstraint = template?.sdkConstraint ?? '^3.0.0'; final isFlutter = package.startsWith('flutter_'); final screenshot = TestScreenshot.success(); @@ -121,8 +122,8 @@ class ImportSource { 'name': package, 'version': version, 'description': '$package is awesome', - if (hasHomepage) 'homepage': 'https://$package.example.com/', - if (hasRepository) 'repository': 'https://github.com/example/$package', + if (homepage.isNotEmpty) 'homepage': homepage, + if (repository.isNotEmpty) 'repository': repository, 'environment': { 'sdk': '$sdkConstraint', }, @@ -141,8 +142,13 @@ class ImportSource { 'topics': ['chemical-element'], }); + final readmeContent = [ + '# $package\n\nAwesome package.', + if (template?.markdownSamples ?? false) _markdownSamples, + ].join('\n\n'); + archive.addFile('pubspec.yaml', pubspec); - archive.addFile('README.md', '# $package\n\nAwesome package.'); + archive.addFile('README.md', readmeContent); archive.addFile('CHANGELOG.md', '## $version\n\n- updated'); archive.addFile('lib/$package.dart', '''library; diff --git a/app/lib/tool/test_profile/markdown_samples.md b/app/lib/tool/test_profile/markdown_samples.md new file mode 100644 index 0000000000..c1533ee401 --- /dev/null +++ b/app/lib/tool/test_profile/markdown_samples.md @@ -0,0 +1,55 @@ +# Header 1 + +Paragraph with `inline code block`. Overall, the text content here should be +long enough that it will be displayed as multiple lines. It demonstrates the +line height and we may also use it to track subtle changes in the layout +(maybe enable hyphens?). + +## Header 2 - also a longer block of text that should be breaking into multiple lines even in desktop view + +Paragraph with **bold text**. + +*** + +Separated by a line, also using *italic formatting*. + +### Header 3 + +Paragraph with [link and `inline code`](https://pub.dev/). + +#### Header 4 +##### Header 5 +###### Header6 + +> Blockquote with unordered list: +> - item 1 +> - item 2 + +Ordered list and list nesting: +1. item 1. +1. item 2. + 1. item 2.1. + 1. item 2.2. +1. item 3. +on multiple lines + +```dart +void main() {} +``` + +![image](https://pub.dev/static/img/pub-dev-logo.svg) + +> [!NOTE] +> Highlights information that users should take into account, even when skimming. + +> [!TIP] +> Optional information to help a user be more successful. + +> [!IMPORTANT] +> Crucial information necessary for users to succeed. + +> [!WARNING] +> Critical content demanding immediate user attention due to potential risks. + +> [!CAUTION] +> Negative potential consequences of an action. diff --git a/app/lib/tool/test_profile/models.dart b/app/lib/tool/test_profile/models.dart index a6de185f1c..7645337a6f 100644 --- a/app/lib/tool/test_profile/models.dart +++ b/app/lib/tool/test_profile/models.dart @@ -184,10 +184,16 @@ class GeneratedTestVersion extends TestVersion { @JsonSerializable(explicitToJson: true, includeIfNull: false) class TestArchiveTemplate { + final String? homepage; + final String? repository; final String? sdkConstraint; + final bool? markdownSamples; TestArchiveTemplate({ + this.homepage, + this.repository, this.sdkConstraint, + this.markdownSamples, }); factory TestArchiveTemplate.fromJson(Map json) => @@ -196,7 +202,10 @@ class TestArchiveTemplate { TestArchiveTemplate overrideWith(TestArchiveTemplate? other) { if (other == null) return this; return TestArchiveTemplate( + homepage: other.homepage ?? homepage, + repository: other.repository ?? repository, sdkConstraint: other.sdkConstraint ?? sdkConstraint, + markdownSamples: other.markdownSamples ?? markdownSamples, ); } diff --git a/app/lib/tool/test_profile/models.g.dart b/app/lib/tool/test_profile/models.g.dart index bdcf11759e..9467195568 100644 --- a/app/lib/tool/test_profile/models.g.dart +++ b/app/lib/tool/test_profile/models.g.dart @@ -151,13 +151,19 @@ Map _$GeneratedTestVersionToJson( TestArchiveTemplate _$TestArchiveTemplateFromJson(Map json) => TestArchiveTemplate( + homepage: json['homepage'] as String?, + repository: json['repository'] as String?, sdkConstraint: json['sdkConstraint'] as String?, + markdownSamples: json['markdownSamples'] as bool?, ); Map _$TestArchiveTemplateToJson( TestArchiveTemplate instance) => { + if (instance.homepage case final value?) 'homepage': value, + if (instance.repository case final value?) 'repository': value, if (instance.sdkConstraint case final value?) 'sdkConstraint': value, + if (instance.markdownSamples case final value?) 'markdownSamples': value, }; TestPublisher _$TestPublisherFromJson(Map json) => diff --git a/app/test/frontend/golden/pkg_show_page.html b/app/test/frontend/golden/pkg_show_page.html index 34c2d13724..f1d4adfcd7 100644 --- a/app/test/frontend/golden/pkg_show_page.html +++ b/app/test/frontend/golden/pkg_show_page.html @@ -132,15 +132,6 @@

%%x-ago%% - • Latest: - - 1.2.0 - - / - - Prerelease: - 2.0.0-dev -
@@ -223,6 +214,90 @@

#

Awesome package.

+

+ Header 1 + # +

+

+ Paragraph with + inline code block + . Overall, the text content here should be long enough that it will be displayed as multiple lines. It demonstrates the line height and we may also use it to track subtle changes in the layout (maybe enable hyphens?). +

+

+ Header 2 - also a longer block of text that should be breaking into multiple lines even in desktop view + # +

+

+ Paragraph with + bold text + . +

+
+

+ Separated by a line, also using + italic formatting + . +

+

+ Header 3 + # +

+

+ Paragraph with + + link and + inline code + + . +

+

Header 4

+
Header 5
+
Header6
+
+

Blockquote with unordered list:

+
    +
  • item 1
  • +
  • item 2
  • +
+
+

Ordered list and list nesting:

+
    +
  1. item 1.
  2. +
  3. + item 2. +
      +
    1. item 2.1.
    2. +
    3. item 2.2.
    4. +
    +
  4. +
  5. item 3. on multiple lines
  6. +
+
+                    void main() {}
+                  
+

+ image +

+
+

Note

+

Highlights information that users should take into account, even when skimming.

+
+
+

Tip

+

Optional information to help a user be more successful.

+
+
+

Important

+

Crucial information necessary for users to succeed.

+
+
+

Warning

+

Critical content demanding immediate user attention due to potential risks.

+
+
+

Caution

+

Negative potential consequences of an action.

+
@@ -297,7 +372,7 @@

More

- +