equal
deleted
inserted
replaced
1 import ammonite.ops._ |
1 import ammonite.ops._ |
2 import mill._ |
2 import mill._ |
3 import mill.define.{Input, Target} |
3 import mill.define.{Input, Sources, Target} |
4 import mill.scalajslib._ |
4 import mill.scalajslib._ |
5 import mill.scalalib._ |
5 import mill.scalalib._ |
6 import mill.scalalib.publish._ |
6 import mill.scalalib.publish._ |
7 import mill.util.Loose |
7 import mill.util.Loose |
8 |
8 |
106 |
106 |
107 trait Content extends Common { |
107 trait Content extends Common { |
108 |
108 |
109 override def moduleDeps = Seq(base) |
109 override def moduleDeps = Seq(base) |
110 |
110 |
111 def contentSources: Target[PathRef] |
111 def contentSources: Sources |
112 |
112 |
113 override def generatedSources: Target[Seq[PathRef]] = T{ |
113 override def generatedSources: Target[Seq[PathRef]] = T{ |
114 val dir = T.ctx().dest |
114 val dir = T.ctx().dest |
115 val src = contentSources().path |
115 val src = contentSources() map(_.path) |
116 val ids = ls! src filter(_.name endsWith ".scalatex") map { p => |
116 val ids = src flatMap(ls! _ filter(_.name endsWith ".scalatex") map { p => |
117 val id = p.name replaceAllLiterally (".scalatex", "") |
117 val id = p.name replaceAllLiterally (".scalatex", "") |
118 val aid = s"article-$id" |
118 val aid = s"article-$id" |
119 write(dir / s"$id.scala", |
119 write(dir / s"$id.scala", |
120 s""" |
120 s""" |
121 | package sqwl.cms |
121 | package sqwl.cms |
126 | import sqwl.cms.Articles.article |
126 | import sqwl.cms.Articles.article |
127 | object `$aid` { |
127 | object `$aid` { |
128 | implicit val id = Articles.Id("$id") |
128 | implicit val id = Articles.Id("$id") |
129 | twf("${p.toString}") |
129 | twf("${p.toString}") |
130 | } |
130 | } |
|
131 | |
|
132 |/* |
|
133 |${os.read(p).lines mkString "\n"} |
|
134 |*/ |
131 """.stripMargin) |
135 """.stripMargin) |
132 aid |
136 aid |
133 } |
137 }) |
134 |
138 |
135 write(dir / "initializer.scala", |
139 write(dir / "initializer.scala", |
136 s""" |
140 s""" |
137 | package sqwl.cms |
141 | package sqwl.cms |
138 | object InitializeContent { |
142 | object InitializeContent { |
159 ivy"com.beachape::enumeratum:1.5.13" |
163 ivy"com.beachape::enumeratum:1.5.13" |
160 ) |
164 ) |
161 } |
165 } |
162 |
166 |
163 object example extends Content { |
167 object example extends Content { |
164 def contentSources: Target[PathRef] = |
168 def contentSources: Sources = |
165 T{ PathRef(millSourcePath / up / 'example / 'content) } |
169 T.sources{ millSourcePath / up / 'example / 'content } |
166 } |
170 } |
167 |
171 |
168 object production extends Content { |
172 object production extends Content { |
169 def contentSources: Target[PathRef] = |
173 def contentSources: Sources = |
170 T{ PathRef(millSourcePath / up / 'production / 'content) } |
174 T.sources{ millSourcePath / up / 'production / 'content } |
171 } |
175 } |
172 |
176 |
173 |
177 |
174 object js extends Common with ScalaJSModule { |
178 object js extends Common with ScalaJSModule { |
175 def scalaJSVersion: Target[String] = scalaJsVer |
179 def scalaJSVersion: Target[String] = scalaJsVer |