-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
124 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.5.0 | ||
|
||
* add windows publish script. | ||
|
||
## 0.4.1 | ||
|
||
* fix windows symbol link do not work. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
function Test-CommandExists { | ||
param($command) | ||
try { | ||
if (Get-Command $command -errorAction SilentlyContinue) { | ||
return $true | ||
} | ||
else { | ||
return $false | ||
} | ||
} | ||
catch { | ||
return $false | ||
} | ||
} | ||
|
||
$exist = Test-CommandExists "flutter" | ||
if (!$exist) { | ||
Write-Error "flutter command do not exist." | ||
exit -1 | ||
} | ||
# set-proxy for publish | ||
if (Test-CommandExists "proxy") { | ||
proxy | ||
} | ||
|
||
$PUB_HOSTED_URL = $env:PUB_HOSTED_URL | ||
$env:PUB_HOSTED_URL = "" | ||
Push-Location tools | ||
try { | ||
flutter pub get | ||
flutter pub run .\bin\publish.dart | ||
} | ||
finally { | ||
Pop-Location | ||
$env:PUB_HOSTED_URL = $PUB_HOSTED_URL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
cd tools | ||
pub get | ||
pub run ./publish.dart | ||
pub run ./bin/publish.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:path/path.dart' as path; | ||
|
||
main(List<String> args) async { | ||
final temDir = Directory.systemTemp.createTempSync("system_clock"); | ||
print("temDir = ${temDir.path}"); | ||
if (temDir.existsSync()) { | ||
temDir.deleteSync(recursive: true); | ||
} | ||
temDir.createSync(recursive: true); | ||
final rootPath = Process.runSync("git", ["rev-parse", "--show-toplevel"]); | ||
if (rootPath.exitCode != 0) { | ||
throw "Not a git project?"; | ||
} | ||
await _copy(Directory(rootPath.stdout.toString().trim()), temDir); | ||
await _publish(temDir); | ||
} | ||
|
||
Future<void> _copy(Directory from, Directory dest) async { | ||
final files = Process.runSync( | ||
"git", | ||
["ls-files", "--cached", "--others", "--exclude-standard"], | ||
workingDirectory: from.path, | ||
).outputLines.map((e) => e.platformPath).toSet(); | ||
|
||
from.listSync(recursive: true, followLinks: false).forEach((var entity) { | ||
final entityRelativePath = path.relative(entity.path, from: from.path).platformPath; | ||
if (!files.contains(entityRelativePath)) { | ||
return; | ||
} | ||
final dir = Directory(path.join(dest.path, path.dirname(entityRelativePath))); | ||
if (!dir.existsSync()) { | ||
dir.createSync(recursive: true); | ||
} | ||
if (entity is File) { | ||
entity.copySync(path.join(dest.path, entityRelativePath)); | ||
} else if (entity is Link) { | ||
final newFilePath = path.normalize(path.join(dest.path, entityRelativePath)); | ||
final target = File(path.normalize(path.absolute(path.dirname(entity.absolute.path), entity.targetSync()))); | ||
target.copySync(newFilePath); | ||
} | ||
}); | ||
} | ||
|
||
extension on String { | ||
String get platformPath { | ||
if (Platform.isWindows) { | ||
return replaceAll("/", "\\"); | ||
} else { | ||
return replaceAll("\\", "/"); | ||
} | ||
} | ||
} | ||
|
||
extension on ProcessResult { | ||
List<String> get outputLines { | ||
if (exitCode != 0) { | ||
throw "Can't get stdout. exitCode = $exitCode"; | ||
} | ||
final out = this.stdout.toString().trim(); | ||
return LineSplitter.split(out).toList(); | ||
} | ||
} | ||
|
||
Future<void> _publish(Directory dir) async { | ||
final process = await Process.start("pwsh", ["-Command", "flutter", "pub", "publish"], workingDirectory: dir.path); | ||
process.stdin.addStream(stdin); | ||
stdout.addStream(process.stdout); | ||
stderr.addStream(process.stderr); | ||
final code = await process.exitCode; | ||
if (code != 0) { | ||
exit(code); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.