From 4fc667eb8da46d9a487be9381e5fdbe62b5dc72c Mon Sep 17 00:00:00 2001 From: chee Date: Tue, 12 Feb 2019 09:06:31 +0000 Subject: [PATCH] OK --- .gitignore | 1 + Origami/ConvertManifest/bower.json | 24 ++++++++++ Origami/ConvertManifest/components.json | 53 +++++++++++++++++++++ Origami/ConvertManifest/convert-manifest.p6 | 49 +++++++++++++++++++ Origami/ConvertManifest/mappings.json | 10 ++++ Semver/Tiny.pm6 | 5 ++ Text/EasyCSV.pm6 | 13 +++++ black-perl.p6 | 28 +++++++++++ convert-manifest.p6 | 49 +++++++++++++++++++ easycsv.p6 | 1 + nothing.p6 | 3 ++ 11 files changed, 236 insertions(+) create mode 100644 .gitignore create mode 100644 Origami/ConvertManifest/bower.json create mode 100644 Origami/ConvertManifest/components.json create mode 100755 Origami/ConvertManifest/convert-manifest.p6 create mode 100644 Origami/ConvertManifest/mappings.json create mode 100644 Semver/Tiny.pm6 create mode 100644 Text/EasyCSV.pm6 create mode 100644 black-perl.p6 create mode 100644 convert-manifest.p6 create mode 100644 easycsv.p6 create mode 100644 nothing.p6 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..860f8b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.precomp/ diff --git a/Origami/ConvertManifest/bower.json b/Origami/ConvertManifest/bower.json new file mode 100644 index 0000000..c6e1ea6 --- /dev/null +++ b/Origami/ConvertManifest/bower.json @@ -0,0 +1,24 @@ +{ + "name": "o-table", + "dependencies": { + "o-colors": "^4.0.0", + "o-grid": "^4.0.6", + "o-icons": ">=4.0.0 <6", + "o-typography": "^5.0.0", + "o-brand": "^3.1.1", + "o-visual-effects": "^2.0.3", + "o-buttons": "^5.14.0", + "dom-delegate": "ftdomdelegate#^2.2.0" + }, + "main": [ + "main.scss", + "main.js" + ], + "ignore": [ + ".gitignore", + "build", + "test", + "karma.conf.js", + "package.json" + ] +} diff --git a/Origami/ConvertManifest/components.json b/Origami/ConvertManifest/components.json new file mode 100644 index 0000000..c80cc17 --- /dev/null +++ b/Origami/ConvertManifest/components.json @@ -0,0 +1,53 @@ +[ + "fticons", + "o-assets", + "o-autoinit", + "o-banner", + "o-brand", + "o-buttons", + "o-colors", + "o-cookie-message", + "o-date", + "o-dom", + "o-element-visibility", + "o-errors", + "o-expander", + "o-fetch-jsonp", + "o-fonts", + "o-footer", + "o-footer-services", + "o-forms", + "o-ft-affiliate-ribbon", + "o-grid", + "o-header", + "o-header-services", + "o-hierarchical-nav", + "o-hoverable", + "o-icons", + "o-labels", + "o-layers", + "o-layout", + "o-link-list", + "o-loading", + "o-message", + "o-normalise", + "o-overlay", + "o-quote", + "o-share", + "o-squishy-list", + "o-subs-card", + "o-syntax-highlight", + "o-table", + "o-tabs", + "o-teaser", + "o-teaser-collection", + "o-techdocs", + "o-toggle", + "o-tooltip", + "o-topper", + "o-typography", + "o-utils", + "o-video", + "o-viewport", + "o-visual-effects" +] diff --git a/Origami/ConvertManifest/convert-manifest.p6 b/Origami/ConvertManifest/convert-manifest.p6 new file mode 100755 index 0000000..2237dd7 --- /dev/null +++ b/Origami/ConvertManifest/convert-manifest.p6 @@ -0,0 +1,49 @@ +#!/usr/bin/env perl6 +use JSON::Pretty; +my $components = from-json(slurp "components.json"); +my $mappings = from-json(slurp "components.json"); + +sub add-npm-org (Str $name) { + return qq「@financial-times/{$name}」; +} + +sub create-npm-dependency (Str $name, Str $version) { + my $is-origami-component = $components.contains($name); + + if ($is-origami-component) { + return add-npm-org($name), $version; + } + + my $name-is-mapped = $mappings.keys.contains($name); + if ($name-is-mapped) { + return $mappings<<$name>>, $version; + } + + my $version-is-mapped = $mappings.keys.contains($version); + if ($version-is-mapped) { + return $name, $mappings<<$version>>; + } + + my $hash-version-match = $version ~~ /'#'(\^?\d+\.\d+\.\d+)/; + if ($hash-version-match.so) { + return $name, @$hash-version-match[0].Str; + } + + return $name, $version; +} + +sub MAIN (Str $version where * ~~ /^\d+\.\d+\.\d+$/) { + my $bowerManifest = from-json(lines); + my $packageManifest = {}; + $packageManifest = $version; + + $packageManifest = add-npm-org($bowerManifest); + $packageManifest = $bowerManifest; + $packageManifest = $bowerManifest; + $packageManifest = $bowerManifest; + $packageManifest = $bowerManifest.map({ + my ($name, $version) = create-npm-dependency(.key, .value); + Pair.new: $name, $version; + }).Hash; + put to-json($packageManifest); +} diff --git a/Origami/ConvertManifest/mappings.json b/Origami/ConvertManifest/mappings.json new file mode 100644 index 0000000..b3a9985 --- /dev/null +++ b/Origami/ConvertManifest/mappings.json @@ -0,0 +1,10 @@ +{ + "name": { + "ftdomdelegate": "dom-delegate", + "prism": "prismjs", + "hogan": "hogan.js" + }, + "version": { + "Financial-Times/highlight.js-shim": "^8.4.0" + } +} diff --git a/Semver/Tiny.pm6 b/Semver/Tiny.pm6 new file mode 100644 index 0000000..3495aea --- /dev/null +++ b/Semver/Tiny.pm6 @@ -0,0 +1,5 @@ +grammar Semver is export { + token TOP {[ + | | | | | + ]} +} diff --git a/Text/EasyCSV.pm6 b/Text/EasyCSV.pm6 new file mode 100644 index 0000000..13c743d --- /dev/null +++ b/Text/EasyCSV.pm6 @@ -0,0 +1,13 @@ +unit class Text::EasyCSV; +use Text::CSV; +my $csv = Text::CSV.new; + +sub load-csv ($path) is export { + my $io = open( + $path, + :r, + chomp => False + ); + my @data = $csv.getline_all($io); + return @data; +} diff --git a/black-perl.p6 b/black-perl.p6 new file mode 100644 index 0000000..696c266 --- /dev/null +++ b/black-perl.p6 @@ -0,0 +1,28 @@ +BEFOREHAND: close door, each window and exit; wait until time; + open spell book; study; read (spell, scan, select); tell us; +write it, print the hex while each watches, + reverse length, write again; + kill spiders, + pop them, + chop them, + split them, + kill them; + unlink arms, shift, wait and listen (listening, wait); +sort the flock (then, warn "the goats", kill "the sheep"); + kill them, dump qualms, shift moralities, + values aside, each one + die sheep; die (to, reverse the => system + you accept (reject, respect)); +next step, + kill next sacrifice, each sacrifice, + wait, redo ritual until "all the spirits are pleased"; + do it ("as they say"); +do it($*everyone*must*participate*in*forbidden*s*e*x*); +return last victim; unit package body; + exit crypt (time, times and "half a time") & close it. + select(quickly) and warn next victim; +AFTERWARDS: tell nobody. + wait, wait until time; + wait until next year, next decade; + sleep, sleep, die yourself, + die at last diff --git a/convert-manifest.p6 b/convert-manifest.p6 new file mode 100644 index 0000000..b859e3c --- /dev/null +++ b/convert-manifest.p6 @@ -0,0 +1,49 @@ +#!/usr/bin/env perl6 +use JSON::Tiny; +my $components = from-json(slurp "components.json"); +my $mappings = from-json(slurp "components.json"); + +sub add-npm-org (Str $name) { + return qq「@financial-times/{$name}」; +} + +sub create-npm-dependency (Str $name, Str $version) { + my $is-origami-component = $components.contains($name); + + my $name-is-mapped = $mappings.keys.contains($name); + my $version-is-mapped = $mappings.keys.contains($version); + + if ($is-origami-component) { + return $name, $version; + } + + if ($name-is-mapped) { + return $mappings<<$name>>, $version; + } + + if ($version-is-mapped) { + return $name, $mappings<<$version>>; + } + + return $name, $version; +} + +sub MAIN (Str $version where * ~~ /^\d+\.\d+\.\d+$/) { + my $bowerManifest = from-json(lines); + my $packageManifest = {}; + $packageManifest = $version; + my ( + $name, + $description, + $homepage, + $license, + $dependencies + ) = $bowerManifest; + + $packageManifest = add-npm-org($name); + $packageManifest = $description; + $packageManifest = $homepage; + $packageManifest = $dependencies.hyper.map(&create-npm-dependency); + + put to-json($packageManifest); +} diff --git a/easycsv.p6 b/easycsv.p6 new file mode 100644 index 0000000..e64632c --- /dev/null +++ b/easycsv.p6 @@ -0,0 +1 @@ +use Text::CSV diff --git a/nothing.p6 b/nothing.p6 new file mode 100644 index 0000000..4f6b42b --- /dev/null +++ b/nothing.p6 @@ -0,0 +1,3 @@ +sub nothing is export { + say "nothing" +}