Skip to content

Commit

Permalink
clean,准备lib/pages 改为 lib/routes
Browse files Browse the repository at this point in the history
  • Loading branch information
chen56 committed Apr 27, 2024
1 parent 1415beb commit 107d753
Show file tree
Hide file tree
Showing 120 changed files with 195 additions and 194 deletions.
218 changes: 109 additions & 109 deletions notes/flutter_web/lib/routes.g.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
flutter run --device-id chrome --web-renderer canvaskit --release --dart-define=FLUTTER_WEB_CANVASKIT_URL=https://cdn.jsdelivr.net/npm/[email protected]/bin/
# build 也有效
flutter build web -v --release --web-renderer canvaskit --dart-define=FLUTTER_WEB_CANVASKIT_URL=https://cdn.jsdelivr.net/npm/[email protected]/bin/ -t lib/pages/navigator/navigator_v2/3.1.navigator_v2_args_screen.dart
flutter build web -v --release --web-renderer canvaskit --dart-define=FLUTTER_WEB_CANVASKIT_URL=https://cdn.jsdelivr.net/npm/[email protected]/bin/ -t lib/routes/navigator/navigator_v2/3.1.navigator_v2_args_screen.dart
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ void build(BuildContext context, Cell print) async {
# asset
'''));
var jsonAsset = await rootBundle.loadString('lib/pages/note.dart');
var jsonAsset = await rootBundle.loadString('lib/routes/note.dart');
print(jsonAsset);
}
File renamed without changes.
File renamed without changes.
109 changes: 54 additions & 55 deletions notes/flutter_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,62 +61,61 @@ dev_dependencies:
flutter:
uses-material-design: true

# if app can not start , you can remove all prefix "lib/pages/*" assets , it is auto generated by note_tools
# if app can not start , you can remove all prefix "lib/routes/*" assets , it is auto generated by note_tools
assets:
- lib/pages.g.json
- lib/pages/notes/
- lib/pages/notes/Improve_app/
- lib/pages/notes/Improve_app/1.overview/
- lib/pages/notes/Improve_app/RepaintBoundary/
- lib/pages/notes/Improve_app/event&listener&lifeycle/
- lib/pages/notes/Improve_app/web_optimization/
- lib/pages/notes/dev/debug/
- lib/pages/notes/dev/devtool/
- lib/pages/notes/dev/devtool/vmservice/
- lib/pages/notes/dev/host_mirror/
- lib/pages/notes/dev/macos_config/
- lib/pages/notes/env_info/
- lib/pages/notes/i18n/
- lib/pages/notes/layout/
- lib/pages/notes/layout/box_layout/constraints/
- lib/pages/notes/layout/old/layout/
- lib/pages/notes/layout/responsive_design/
- lib/pages/notes/media&assets&file/assets/
- lib/pages/notes/media&assets&file/file_desktop/
- lib/pages/notes/media&assets&file/file_web/
- lib/pages/notes/navigation/
- lib/pages/notes/pure_dart/analyzer/
- lib/pages/notes/pure_dart/async/
- lib/pages/notes/pure_dart/dart3/
- lib/pages/notes/pure_dart/execption/
- lib/pages/notes/pure_dart/safe_interface/
- lib/pages/notes/pure_dart/serialization_json/
- lib/pages/notes/research/remote_view/
- lib/pages/notes/research/research_parameterized_example/
- lib/pages/notes/state/
- lib/pages/notes/state/1.vanilla_state/
- lib/pages/notes/state/StatefulBuilder/
- lib/pages/notes/style&theming/material3/
- lib/pages/notes/thinking_in_ui/readable_html_vs_dart/
- lib/pages/notes/widgets/container_widgets/bar/
- lib/pages/notes/widgets/container_widgets/menu/
- lib/pages/notes/widgets/container_widgets/scrollable/Dismissible/
- lib/pages/notes/widgets/specific_widgets/button/ButtonStyleButton/
- lib/pages/notes/widgets/specific_widgets/button/FloatingActionButton/
- lib/pages/notes/widgets/specific_widgets/button/IconButton/
- lib/pages/notes/widgets/specific_widgets/button/overview/
- lib/pages/notes/widgets/specific_widgets/icon/
- lib/pages/notes/widgets/specific_widgets/input/
- lib/pages/notes/widgets/specific_widgets/selectable/
- lib/pages/notes/widgets/specific_widgets/slider/
- lib/pages/notes/widgets/specific_widgets/text/RichText/
- lib/pages/notes/widgets/specific_widgets/text/Text/
- lib/pages/notes/widgets/specific_widgets/webview/
- lib/pages/notes/x.note_inside/1.welcome/
- lib/pages/notes/x.note_inside/how_note_work/
- lib/pages/notes/x.note_inside/mockup_content/
- lib/pages/notes/x.note_inside/note_test_self/
- lib/pages/notes/x.note_inside/note_test_self/nobody/
- lib/routes/notes/
- lib/routes/notes/Improve_app/
- lib/routes/notes/Improve_app/1.overview/
- lib/routes/notes/Improve_app/RepaintBoundary/
- lib/routes/notes/Improve_app/event&listener&lifeycle/
- lib/routes/notes/Improve_app/web_optimization/
- lib/routes/notes/dev/debug/
- lib/routes/notes/dev/devtool/
- lib/routes/notes/dev/devtool/vmservice/
- lib/routes/notes/dev/host_mirror/
- lib/routes/notes/dev/macos_config/
- lib/routes/notes/env_info/
- lib/routes/notes/i18n/
- lib/routes/notes/layout/
- lib/routes/notes/layout/box_layout/constraints/
- lib/routes/notes/layout/old/layout/
- lib/routes/notes/layout/responsive_design/
- lib/routes/notes/media&assets&file/assets/
- lib/routes/notes/media&assets&file/file_desktop/
- lib/routes/notes/media&assets&file/file_web/
- lib/routes/notes/navigation/
- lib/routes/notes/pure_dart/analyzer/
- lib/routes/notes/pure_dart/async/
- lib/routes/notes/pure_dart/dart3/
- lib/routes/notes/pure_dart/execption/
- lib/routes/notes/pure_dart/safe_interface/
- lib/routes/notes/pure_dart/serialization_json/
- lib/routes/notes/research/remote_view/
- lib/routes/notes/research/research_parameterized_example/
- lib/routes/notes/state/
- lib/routes/notes/state/1.vanilla_state/
- lib/routes/notes/state/StatefulBuilder/
- lib/routes/notes/style&theming/material3/
- lib/routes/notes/thinking_in_ui/readable_html_vs_dart/
- lib/routes/notes/widgets/container_widgets/bar/
- lib/routes/notes/widgets/container_widgets/menu/
- lib/routes/notes/widgets/container_widgets/scrollable/Dismissible/
- lib/routes/notes/widgets/specific_widgets/button/ButtonStyleButton/
- lib/routes/notes/widgets/specific_widgets/button/FloatingActionButton/
- lib/routes/notes/widgets/specific_widgets/button/IconButton/
- lib/routes/notes/widgets/specific_widgets/button/overview/
- lib/routes/notes/widgets/specific_widgets/icon/
- lib/routes/notes/widgets/specific_widgets/input/
- lib/routes/notes/widgets/specific_widgets/selectable/
- lib/routes/notes/widgets/specific_widgets/slider/
- lib/routes/notes/widgets/specific_widgets/text/RichText/
- lib/routes/notes/widgets/specific_widgets/text/Text/
- lib/routes/notes/widgets/specific_widgets/webview/
- lib/routes/notes/x.note_inside/1.welcome/
- lib/routes/notes/x.note_inside/how_note_work/
- lib/routes/notes/x.note_inside/mockup_content/
- lib/routes/notes/x.note_inside/note_test_self/
- lib/routes/notes/x.note_inside/note_test_self/nobody/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware

Expand Down
2 changes: 1 addition & 1 deletion notes/flutter_web/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_web/pages/notes/widgets/container_widgets/Card/sample1.dart';
import 'package:flutter_web/routes/notes/widgets/container_widgets/Card/sample1.dart';
import 'package:flutter_test/flutter_test.dart';


Expand Down
16 changes: 8 additions & 8 deletions packages/you_cli/bin/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import 'package:you_cli/src/yaml.dart';
// ignore: constant_identifier_names
const String _LIB_ROOT = "lib";
// ignore: constant_identifier_names
const String _NOTES_ROOT = "lib/pages/notes";
const String _NOTES_ROOT = "lib/routes/notes";
// ignore: constant_identifier_names
const String _PAGES_ROOT = "lib/pages";
const String _PAGES_ROOT = "lib/routes";
// ignore: non_constant_identifier_names
final Glob _PAGE_GLOB = Glob("{**/page.dart,page.dart}");

Expand Down Expand Up @@ -54,7 +54,7 @@ class CliSystem {

Directory get libDir => pkgDir.childDirectory(_LIB_ROOT);

Stream<PageLib> pages() {
Stream<PageLib> routes() {
var noteRootDir = pkgDir.childDirectory(_NOTES_ROOT);
return _PAGE_GLOB.listFileSystem(fs, root: noteRootDir.path).where((e) => e is File).map((e) => PageLib(
file: e as File,
Expand Down Expand Up @@ -225,7 +225,7 @@ ${node.children.map((child) => _genRouteTreeCode(child)).map((e) => "$e,").join(
import 'package:you_flutter/router.dart';
// ###########################################
// ## pages
// ## routes
// ###########################################
$pageImportsCode
Expand All @@ -252,7 +252,7 @@ $newRoutes

class PageLib {
final FileSystem fs;
final Directory pagesRootDir;
final Directory routesRootDir;
final Directory libDir;
final String pkgName;
final File file;
Expand All @@ -264,10 +264,10 @@ class PageLib {
required this.pkgDir,
}) : fs = file.fileSystem,
libDir = pkgDir.childDirectory(_LIB_ROOT),
pagesRootDir = pkgDir.childDirectory(_PAGES_ROOT);
routesRootDir = pkgDir.childDirectory(_PAGES_ROOT);

String get noteRoutePath {
String result = path.dirname(path.relative(file.path, from: pagesRootDir.path));
String result = path.dirname(path.relative(file.path, from: routesRootDir.path));
return result == "." ? "/" : path.join("/", result);
}

Expand All @@ -277,7 +277,7 @@ class PageLib {
String get asset => "${path.relative(file.parent.path, from: pkgDir.path)}/";

/// note name平整化,可作为变量名:
/// lib/pages/1.a/b/page.dart ---> a_b
/// lib/routes/1.a/b/page.dart ---> a_b
String get flatName {
String dir = noteRoutePath;
if (dir == "/") {
Expand Down
2 changes: 1 addition & 1 deletion packages/you_cli/lib/src/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RouteNode {
}

/// note name平整化,可作为变量名:
/// lib/pages/1.a/b/page.dart ---> a_b
/// lib/routes/1.a/b/page.dart ---> a_b
String get flatName {
String p = routePath;
if (p == "/") {
Expand Down
4 changes: 2 additions & 2 deletions packages/you_cli/lib/src/yaml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PubspecEdit {
for (int i = 0; i < oldAssets.length; i++) {
var oldAsset = oldAssets[i];
// manual config, leave it
// lib/pages is our Generated
// lib/routes is our Generated
if (!oldAsset.startsWith(toUpdatePath)) {
continue;
}
Expand All @@ -81,7 +81,7 @@ class PubspecEdit {
continue;
}

// prefix lib/pages is previously Generated ,and now not exists
// prefix lib/routes is previously Generated ,and now not exists
_yamlEditor.remove([..._yamlPathAssets, i - removed]);
removed++;
}
Expand Down
14 changes: 8 additions & 6 deletions packages/you_cli/test/bin/page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ void main() {
group("PageNode", () {
test('create from directory', () {
late MemoryFileSystem fs = MemoryFileSystem();
fs.directory("/note/lib/pages/notes/page_1").createSync(recursive: true);
fs.directory("/note/lib/pages/notes/page_1/page_1_1").createSync(recursive: true);
fs.directory("/note/lib/pages/notes/page_1/page_1_2").createSync(recursive: true);
var rootPage = RouteNode.fromSync(fs.directory("/note/lib/pages"));
fs.directory("/note/lib/routes/notes/page_1").createSync(recursive: true);
fs.directory("/note/lib/routes/notes/page_1/page_1_1").createSync(recursive: true);
fs.directory("/note/lib/routes/notes/page_1/page_1_2").createSync(recursive: true);
var rootPage = RouteNode.fromSync(fs.directory("/note/lib/routes"));
check(rootPage.toList().map((e) => e.routePath)).deepEquals([
"/",
"/notes",
Expand All @@ -26,12 +26,14 @@ void main() {
group("Gen routes.g.dart", () {
test('create from directory', () {
late MemoryFileSystem fs = MemoryFileSystem();
fs.file("/app/pubspec.yaml")..createSync(recursive: true)..writeAsString("""name: you""");

fs.file("/app/lib/routes/page.dart").createSync(recursive: true);
fs.file("/app/lib/routes/layout.dart").createSync(recursive: true);

CliSystem cli = CliSystem(pkgDir: fs.directory("/app"));
Cmd_gen_routes_g_dart gen=Cmd_gen_routes_g_dart.libMode(fs: fs, async: true, dir: fs.directory("/app/lib/pages"));
// gen.builderExpression(dir);
Cmd_gen_routes_g_dart gen=Cmd_gen_routes_g_dart.libMode(fs: fs, async: true, dir: fs.directory("/app/lib/routes"));
gen.builderExpression(cli.routeRoot);
//
// var rootRoute = RouteDir.fromSync(dir);
// check(rootRoute.toList().map((e) => e.routePath)).deepEquals(["/"]);
Expand Down
12 changes: 6 additions & 6 deletions packages/you_cli/test/bin/pubspec_edit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ flutter:
expect(pubspec.assets, ["assets/manual1"]);

// when
pubspec.updateAssets(toUpdatePath: "lib/pages/notes/", toUpdate: ["lib/pages/notes/new/"]);
pubspec.updateAssets(toUpdatePath: "lib/routes/notes/", toUpdate: ["lib/routes/notes/new/"]);

// then
expect(pubspec.assets, ['assets/manual1', 'lib/pages/notes/new/']);
expect(pubspec.assets, ['assets/manual1', 'lib/routes/notes/new/']);
});

test('remove not exists', () async {
File file = createMemoryPubspecFile("""
flutter:
assets:
- assets/manual1 # manual config, keep it
- lib/pages/notes/rm/ # to remove
- lib/routes/notes/rm/ # to remove
""");
PubspecEdit pubspec = PubspecEdit.parseFileSync(file);
var old = pubspec.assets;
expect(old, ["assets/manual1" ,"lib/pages/notes/rm/"]);
expect(old, ["assets/manual1" ,"lib/routes/notes/rm/"]);

// when
pubspec.updateAssets(toUpdatePath: "lib/pages/notes/", toUpdate: ["lib/pages/notes/new/"]);
pubspec.updateAssets(toUpdatePath: "lib/routes/notes/", toUpdate: ["lib/routes/notes/new/"]);

// then
expect(pubspec.assets, ['assets/manual1', 'lib/pages/notes/new/']);
expect(pubspec.assets, ['assets/manual1', 'lib/routes/notes/new/']);
});
});
}
4 changes: 2 additions & 2 deletions packages/you_note_dart/lib/src/conventions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class Conventions {
Conventions._();

String noteDartAssetPath(String notePath) {
return path.join("lib/pages", path.relative(notePath, from: "/"), "page.dart");
return path.join("lib/routes", path.relative(notePath, from: "/"), "page.dart");
}

String noteConfAssetPath(String notePath) {
return path.join("lib/pages", path.relative(notePath, from: "/"), "page.json");
return path.join("lib/routes", path.relative(notePath, from: "/"), "page.json");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Exception: my throw
"sources": [
"org-dartlang-sdk:///dart-sdk/lib/async/stream.dart",
"org-dartlang-sdk:///dart-sdk/lib/async/stream_controller.dart",
"../../../lib/pages/notes/pure_dart/execption/note.dart",
"../../../lib/routes/notes/pure_dart/execption/note.dart",
"../../../../../packages/you_note_dart/lib/src/note_cell.dart",
"org-dartlang-sdk:///dart-sdk/lib/_internal/js_runtime/lib/js_array.dart",
"org-dartlang-sdk:///dart-sdk/lib/internal/iterable.dart",
Expand Down Expand Up @@ -633,7 +633,7 @@ Exception: my throw
}
"""),
);
check(found.callerFrame!.library).endsWith("lib/pages/notes/pure_dart/execption/note.dart");
check(found.callerFrame!.library).endsWith("lib/routes/notes/pure_dart/execption/note.dart");

// print("=====>${found.dartTrace}");
});
Expand Down

0 comments on commit 107d753

Please sign in to comment.