-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.xml
993 lines (709 loc) · 47 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Recent Content on Angularity </title>
<generator uri="https://hugo.spf13.com">Hugo</generator>
<link>/index.xml/</link>
<updated>Mon, 15 Dec 2014 13:42:50 AEDT</updated>
<item>
<title>Angularity (DEPRECATED)</title>
<link>/about/mission/</link>
<pubDate>Mon, 15 Dec 2014 13:42:50 AEDT</pubDate>
<guid>/about/mission/</guid>
<description>
<h1 id="toc_0"><img src="/assets/logo.png" alt="Angularity Logo" />
</h1>
<blockquote>
<p><strong>&ndash; IMPORTANT ANNOUNCEMENT &ndash;</strong></p>
<p>Angularity is now <strong>deprecated</strong> and may be removed at any time.</p>
<p>Do <strong>not</strong> use for new projects.</p>
<p>Use the <a href="https://www.npmjs.com/package/webpack-angularity-solution">Webpack implementation</a> for existing Angularity (Browserify/SASS) projects using <strong>Angular 1.x</strong>.</p>
</blockquote>
<p>A philosophy of development</p>
<p>Uniformity across groups of developers who hold varying experience levels.</p>
<p>Contributors who hold a collective vision of best-practice AngularJS development and have condensed this into a set of
tools and resources known as <strong>Angularity</strong>.</p>
</description>
</item>
<item>
<title>Concept</title>
<link>/about/concept/</link>
<pubDate>Mon, 15 Dec 2014 13:42:50 AEDT</pubDate>
<guid>/about/concept/</guid>
<description>
<p>Angularity is primarily a <a href="http://nodejs.org/">node.js</a> build tool.</p>
<p>It is intended for organisations with one or more teams developing <a href="https://angularjs.org/">AngularJS</a> applications.</p>
<h2 id="toc_0">Immutable</h2>
<p>Angularity is a wrapper around <a href="http://gulpjs.com/">Gulp</a> such that it does not require a per-project <code>gulpfile.js</code> and
may be distributed as a self-contained npm package.</p>
<p>This allows distribution of a turn-key gulp-like build system to developers.</p>
<table>
<thead>
<tr>
<th>Angularity</th>
<th>Gulp</th>
</tr>
</thead>
<tbody>
<tr>
<td>angularity (global)</td>
<td>gulp (global)</td>
</tr>
<tr>
<td></td>
<td>gulp</td>
</tr>
<tr>
<td></td>
<td>gulpfile.js</td>
</tr>
<tr>
<td></td>
<td>..</td>
</tr>
<tr>
<td></td>
<td><em>N x modules</em></td>
</tr>
</tbody>
</table>
<p>There are plans to allow customisation of the immutable package (for organisations) as well a plugin system (for single
developers). It is more accurate to say Angularity will be somewhat mutable to the degree you allow.</p>
<h2 id="toc_1">Richer</h2>
<p>Angularity is superior to <a href="http://gulpjs.com/">Gulp</a> in that it implements a richer command line interface.</p>
<p>It also provides support for selected development IDEs and Continuous Integration servers.</p>
<h2 id="toc_2">Efficient</h2>
<p>Angularity has an emphasis on <strong>composition</strong>. Each project contains one deployable application and any number of
additional non-deployable applications (as needed for development). Each application features a
<a href="http://blog.ploeh.dk/2011/07/28/CompositionRoot/">Composition Root</a> for both Javascript and SASS.</p>
<p>SASS will inherantly bundle any <code>@import</code>ed files and <a href="http://browserify.org/">browserify</a> can bundle <code>require()</code>d
Javascript, HTML template (strings), and sprited images (coming soon). This minimises the application footprint to only
that which is needed.</p>
<p>If you have experience with NInject for .NET, or RobotLegs or Parsley in Flash/Flex these concepts will be familiar to
you. You will see from our <a href="/style/composition">style guide</a> that this pattern is also a superior approach for
AngularJS.</p>
<h2 id="toc_3">Core Features</h2>
<p>Angularity consists the following core features:</p>
<ul>
<li>Single <a href="http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation">global install</a> for all projects.</li>
<li>Bundling of <code>require()</code>&rsquo;d files per <a href="http://browserify.org/">browserify</a>.</li>
<li><a href="http://en.wikipedia.org/wiki/ECMAScript#ECMAScript_Harmony_.286th_Edition.29">ECMAScript 6</a> syntax
(using <a href="https://github.com/6to5/6to5ify">6to5ify</a>).</li>
<li>Composition of <em>html</em> templates in <em>javascript</em>.</li>
<li><a href="http://www.jshint.com/about/">jsHint</a> linting.</li>
<li><a href="http://sass-lang.com/">SASS</a> 3.2 (using <a href="http://libsass.org/">libsass</a>).</li>
<li><a href="http://bower.io/">Bower</a> for web dependencies.</li>
<li><a href="http://bower.io/">Bower</a> or <a href="https://www.npmjs.com/">node packages</a> for common code.</li>
<li>Javascript unit testing (using <a href="http://karma-runner.github.io/0.12/index.html">Karma</a> and
<a href="http://jasmine.github.io/2.0/introduction.html">Jasmine 2.0</a>).</li>
<li>Source maps for Javascript, allowing continuous minification.</li>
<li>Source maps for CSS.</li>
</ul>
<p>Many of these features are not specifically tied to <a href="https://angularjs.org/">AngularJS</a>. However much of
the material you will find on this site is geared to Angular development.</p>
</description>
</item>
<item>
<title>Suitability</title>
<link>/about/suitability/</link>
<pubDate>Mon, 15 Dec 2014 13:42:50 AEDT</pubDate>
<guid>/about/suitability/</guid>
<description>
<h2 id="toc_0">You should use Angularity when&hellip;</h2>
<ul>
<li>Your organisation has a large code/asset library and want to include only the elements you require.</li>
<li>You want your development teams&rsquo; build tooling to be turn-key and immutable.</li>
<li>You develop with <a href="https://angularjs.org/">AngularJS</a> and would like a path to
<a href="http://en.wikipedia.org/wiki/ECMAScript#ECMAScript_Harmony_.286th_Edition.29">ECMAScript 6</a>.</li>
<li>You use <a href="http://sass-lang.com/">SASS</a>, or are prepared to switch, and can live without
<a href="http://compass-style.org/">Compass</a>.</li>
<li>You intend to minify or obfuscate your Javascript.</li>
<li>You your browser support list permits <a href="http://kangax.github.io/compat-table/es5/">ECMAScript 5.1</a>.</li>
<li>You would like your build tool to be a self contained npm package with the option of a global install.</li>
</ul>
<h2 id="toc_1">You should fork Angularity when&hellip;</h2>
<ul>
<li>You want to use a CSS preprocessor other than <a href="http://sass-lang.com/">SASS</a>.</li>
<li>You would like to use <a href="http://compass-style.org/">Compass</a> with your SASS.</li>
<li>You need to support <a href="http://phantomjs.org/">PhantomJS 1.x</a>, Internet Explorer 8 (or lower), or any other platform
inconsistent with <a href="https://6to5.org/">6to5</a> generated code.</li>
</ul>
<h2 id="toc_2">You should avoid Angularity when&hellip;</h2>
<ul>
<li>Your projects are all different and need customised build steps that cannot be generalised.</li>
</ul>
<h2 id="toc_3">Best fit</h2>
<p>Angularity has additional features that support <a href="https://www.jetbrains.com/webstorm/">Webstorm</a> IDE and
<a href="https://www.google.com.au/webhp?sourceid=chrome-instant&amp;ion=1&amp;espv=2&amp;ie=UTF-8#q=team%20city">Team City</a>
Continuous Integration server.</p>
<p>Following version 1.0.0 we will be looking for contributors to add first class support for other popular IDEs and CI
reporters.</p>
<h2 id="toc_4">Bottom line</h2>
<p>Angularity is about uniformity. Per-project customisation is minimal. What customisation exists is focused on
supporting different environments (such as development vs CI server).</p>
<p>If you can generalise you build requirements but want different build steps to those provided then you can fork
Angularity and make your own flavour.</p>
<p>However if you develop a wide variety of applications we recommend you use <a href="http://gulpjs.com/">Gulp</a>, which Angularity
uses under the hood.</p>
</description>
</item>
<item>
<title>Roadmap</title>
<link>/about/roadmap/</link>
<pubDate>Mon, 15 Dec 2014 13:43:03 AEDT</pubDate>
<guid>/about/roadmap/</guid>
<description>
<h3 id="toc_0">Version 0.1.0</h3>
<ul>
<li>Command line invocation of tasks.</li>
<li>Customisation of jsHint reporter.</li>
<li>Customisation of Karma using <code>karma.conf.js</code>.</li>
<li>CDN fingerprinting for the <code>release</code> task.</li>
<li>Retire <code>angularity.json</code> and move contents to <code>package.json</code>.</li>
<li>Webstorm integration.</li>
<li>Documentation:
<ul>
<li>Basic usage</li>
<li>Coding style</li>
<li>Troubleshooting.</li>
</ul></li>
</ul>
<h3 id="toc_1">Version 0.x.0</h3>
<p>To be determined.</p>
<h3 id="toc_2">Version 1.0.0</h3>
<ul>
<li>Global invocation defers to a local Angularity instance, where present.</li>
<li>Synchronisation task the keep selected <code>package.json</code> and <code>bower.json</code> properties in sync.</li>
<li>Interactive command line menus.</li>
<li>Sprite sheeting my browserify composition.</li>
<li>Better extensibility (code cleanup, modularisation)</li>
<li>Unit/Integration tests.</li>
<li>Documentation:
<ul>
<li>Angularity architecture</li>
<li>Guidance on extending Angularity.</li>
</ul></li>
</ul>
</description>
</item>
<item>
<title>Installation</title>
<link>/start/installation/</link>
<pubDate>Mon, 15 Dec 2014 13:43:30 AEDT</pubDate>
<guid>/start/installation/</guid>
<description>
<h2 id="toc_0">Install git</h2>
<p><a href="http://git-scm.com/downloads"><code>http://git-scm.com/downloads</code></a></p>
<p>Ensure that you choose the correct binary for your system.
Meaning that 64 bit systems should choose the 64 bit binary.</p>
<p>For <strong>windows platform</strong>:</p>
<ul>
<li><p>Choose to <strong>use GIT from the command prompt</strong>.<br/>
<img src="/start/installation-git-1.png" alt="Windows git installation step #1" />
</p></li>
<li><p>Choose to <strong>checkout Windows-style, commit Unit-style</strong> for line endings.<br/>
<img src="/start/installation-git-2.png" alt="Windows git installation step #2" />
</p></li>
</ul>
<h2 id="toc_1">Install node.js (v0.10.36)</h2>
<p>Angularity is tested against Node.js version <code>0.10.36</code>.</p>
<h3 id="toc_2">Using a Package Manager</h3>
<p>At this time you cannot install the latest Node.js distribution and expect Angularity to work. In general you will find
that you will need to switch versions of Node.js for different applications.</p>
<p>We strongly recommend you install a Node Version Manager; <a href="https://github.com/creationix/nvm"><code>nvm</code> for mac</a> or
<a href="https://github.com/coreybutler/nvm-windows"><code>nvm-windows</code> for Windows</a>.</p>
<p>Once we have <code>nvm</code> we can then install <code>0.10.36</code>.</p>
<pre><code>nvm install 0.10.36
nvm use 0.10.36
</code></pre>
<p>If you are using <a href="https://github.com/creationix/nvm"><code>nvm</code> for mac</a> then you will <strong>also</strong> need to alias your default
version so that it will run in every shell.</p>
<pre><code>nvm alias default 0.10.36
</code></pre>
<p>Finally, obtain a new shell and make sure that the expected version of node (0.10.36) is running.</p>
<pre><code>node -v
</code></pre>
<h3 id="toc_3"><em>or</em> Directly</h3>
<p>If you prefer to not use NVM or some other package manager you can just install directly but ensure that you choose the
correct binary for your system.</p>
<p><a href="http://nodejs.org/dist/v0.10.36"><code>http://nodejs.org/dist/v0.10.36</code></a></p>
<p>Choose the <strong>default settings</strong> whenever prompted.</p>
<p>On <strong>Windows</strong> platform the installer will add a <strong>path</strong> entry to node. For that to be active you will most likely
need to reboot. With <code>nvm-windows</code> you may have some other issues getting started but it is worth persevering.</p>
<h2 id="toc_4">Update npm</h2>
<p>Even if you just installed NodeJS you may be running npm older than
<a href="http://blog.npmjs.org/post/98131109725/npm-2-0-0">npm <code>2.0.0</code></a>. Check your version.</p>
<pre><code>npm -v
</code></pre>
<p>In our experience if your version is <code>1.x</code> you will have problems installing Angularity.</p>
<p>We recommend upgrading. Be aware however that older projects (not angularity) may not be compatible with
<a href="http://blog.npmjs.org/post/98131109725/npm-2-0-0">npm <code>2.0.0</code></a>.</p>
<pre><code>npm install -g npm
</code></pre>
<p>Check the version again. You are expecting to now see version <code>2.x</code>.</p>
<pre><code>npm -v
</code></pre>
<p>On <strong>windows</strong> you will have some difficulty and the npm version will likely remain at <code>1.x</code>. You will need to follow
these <a href="https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows">instructions</a>. We recommend deleting the
npm instance in <code>program files</code> and keeping the one in your <code>users</code> directory.</p>
<h2 id="toc_5">Install Bower</h2>
<p>Most angularity projects will utilise <a href="http://bower.io/">bower</a>.</p>
<p>Perform a global installation using npm.</p>
<pre><code>npm install -g bower
</code></pre>
<h2 id="toc_6">Install Angularity</h2>
<h3 id="toc_7">Latest Release</h3>
<p>Use the latest release unless if you are new to Angularity or just want the most stable version.</p>
<p>Perform a global installation using npm.</p>
<pre><code>npm install -g angularity
</code></pre>
<h3 id="toc_8"><em>or</em> Pre-Release</h3>
<p>You can install from <a href="https://github.com/angularity/node-angularity">Github</a>. However this is considered bleeding edge.</p>
<pre><code>npm install -g angularity/node-angularity
</code></pre>
<h3 id="toc_9"><em>or</em> Tagged Release</h3>
<p>You can also install from a <a href="https://github.com/angularity/node-angularity">Github</a> tag.</p>
<pre><code>npm install -g angularity/node-angularity#&lt;TAG&gt;
</code></pre>
<h2 id="toc_10">Check installation</h2>
<p>Run the angularity version command to make sure the installation worked.</p>
<pre><code>angularity -v
</code></pre>
<h2 id="toc_11">Install source code</h2>
<p><strong>OPTIONAL</strong></p>
<p>If you wish to develop or contribute to the Angularity project you will need to
<a href="https://github.com/angularity/node-angularity/fork">fork the project</a> on github.</p>
<p>Get local a working copy of your fork.</p>
<pre><code>git clone [email protected]:&lt;YOUR_GITHUB_USERNAME&gt;/node-angularity.git
</code></pre>
<p>Force the global install to defer to this working copy. You still need to have performed the global install above.</p>
<pre><code>npm link
</code></pre>
<p>Be sure to keep your fork in sync with the main repository before you start working on any patch.
This <a href="https://help.github.com/articles/syncing-a-fork/">how to on Github</a> is most helpful.</p>
</description>
</item>
<item>
<title>Project Anatomy</title>
<link>/start/anatomy/</link>
<pubDate>Mon, 15 Dec 2014 13:43:41 AEDT</pubDate>
<guid>/start/anatomy/</guid>
<description>
<p>The best place to start on project anatomy is to create a blank project.</p>
<p>Angularity has an <a href="/tasks/init"><code>init</code></a> task that will create a new project and initialise it. By default, it will
create a new subdirectory.</p>
<p>All Angularity tasks will have default values for any options. So we can go ahead and invoke <code>init</code> simply as below.</p>
<pre><code>angularity init
</code></pre>
<p>You will receive the following files.</p>
<p><img src="/img/anatomy-directory.png" alt="new project directory" />
</p>
<h2 id="toc_0">Composition Root</h2>
<p>The <code>init</code> task will create an <code>/app</code> directory with files <code>index.html</code>, <code>index.js</code>, <code>index.scss</code>.</p>
<p>These files compose the primary application for this project. The entire <code>/app</code> directory should be version controlled.</p>
<blockquote>
<p>You can create additional applications in sub-folders. However they will be development only since they will
not be deployed by the <code>release</code> task.</p>
</blockquote>
<p>Angularity generates other directories as part of its build process. These are prefixed with <code>app</code>, such as <code>app-build</code>
and <code>app-test</code>. These generated directories should be ignored for version control.</p>
<p>All other directories are considered your local library. These files must be <code>require()</code>d or <code>@import</code>ed into <code>index.js</code>
or <code>index.scss</code> respectively.</p>
<h2 id="toc_1">Git Ignore</h2>
<p>Presuming you are using GIT, this file ensures version control will ignore generated directories and bower and npm
packages.</p>
<h2 id="toc_2">JS Hint Config</h2>
<p>A javascript linter is important to ensure code quality. Angularity uses <a href="http://jshint.com/">JS Hint</a>. The JS Hint
rule set is encoded in the <code>.jshintrc</code> file.</p>
<h2 id="toc_3">Angularity Config</h2>
<p>Angularity has a limited number of settings that control your project. These are found in <code>angularity.json</code>.</p>
<h2 id="toc_4">Node and Bower Config</h2>
<p>The composition roots may import from any node or bower packages. The <code>init</code> task creates basic <code>package.json</code> and
<code>bower.json</code> for node and bower respectively.</p>
<p>Each item in the bower <code>dependencies</code> map will be considered distributions and contribute directly to the HTML. Each
item in bower <code>devDependencies</code> will not contribute to the HTML but may be <code>require()</code>d or <code>@import</code>ed into the
composition roots.</p>
<p>Each item in the node package <code>depencencies</code> or <code>devDependencies</code> may be <code>require()</code>d or <code>@import</code>ed into the
composition roots. You may use the simple <code>require(&lt;PACKAGE_NAME&gt;)</code>, meaning that the experience is the same as
developing for the node platform.</p>
<h2 id="toc_5">Karma Config</h2>
<p>Angularity uses <a href="http://karma-runner.github.io/">Karma</a> for unit tests. This is configured using <code>karma.conf.js</code>.</p>
<p>Since Angularity performs a build step, the <code>files</code> and <code>reporter</code> entries will be overwritten by Angularity to create a
derived file <code>/app-test/karma.conf.js</code>.</p>
<h2 id="toc_6">&hellip; Everything Else</h2>
<p>The remaining directories (baring installed bower and node packages) are considered your local library.</p>
<p>There are no special directories for sprites, images, javascript, html partials, css and scss. It is up to you what
conventions you choose. However you organise these files, the composition root will import them will fully relative
paths.</p>
<p>Any file can also import from bower and node packages that are installed, much like you would do when developing for
the NodeJS platform.</p>
<p>This will be more apparent in the next section, when we look at an actual project.</p>
</description>
</item>
<item>
<title>Todo Example</title>
<link>/start/example/</link>
<pubDate>Mon, 15 Dec 2014 13:43:41 AEDT</pubDate>
<guid>/start/example/</guid>
<description>
<p>Now that we are familiar with a blank project, what does an actual project look like? Inevitably Angularity has a
<a href="https://github.com/angularity/angularity-todo-es5">Todo Application</a>.</p>
<p>You can go ahead and clone it using Git.</p>
<blockquote>
<p>By default <code>git clone</code> will create a subdirectory. If you have been working with the blank project from last page,
make sure that you are back in the parent directory.</p>
</blockquote>
<pre><code>git clone https://github.com/angularity/angularity-todo-es5.git
</code></pre>
<p>This gives the following files (or similar)</p>
<p><img src="/img/todo-directory.png" alt="todo directory" />
</p>
<p>Including an npm <a href="https://docs.npmjs.com/files/package.json#bundleddependencies">bundled dependency</a> which we consider a
common library.</p>
<p><img src="/img/todo-bundled.png" alt="todo bundled" />
</p>
<p>You will notice that the folder structure is feature based. There is no restriction as to where images or javascript or
html lives. You may use the scheme that best suits your needs.</p>
<h2 id="toc_0">Dependencies</h2>
<p>Obviously there will be a few external dependencies (not least AngularJS) so go ahead and do a bower and npm install in
the project directory.</p>
<pre><code>npm install
bower install
</code></pre>
<h2 id="toc_1">Composition Root</h2>
<p>The place to start is always the composition root, so take a look at <code>/app/index.js</code>.</p>
<pre><code>var todoRoutes = require('../todo/todo-routes'),
escapeKeyDirective = require('examplelib/interaction/escape-key-directive'),
focusElementDirective = require('examplelib/interaction/focus-element-directive'),
LocalStorage = require('../storage/local-storage');
angular.module('app', [ 'ui.router', 'ui.bootstrap' ])
.config(todoRoutes)
.directive('escape', escapeKeyDirective.forAttribute('escape'))
.directive('focus', focusElementDirective.forAttribute('focus'))
.value('storage', new LocalStorage('todos-angularjs'));
</code></pre>
<p>There is a second compostion root, <code>app/no-storage/index.js</code> that has a mock storage component. We will not discuss this
except to point out that you may make as many additional applications as you need for development purposes.</p>
<h3 id="toc_2">Module definition</h3>
<p>An angularity project is not split between angular modules. Unless we intend this project to be a module for
distribution the module name does not matter.</p>
<p>We can see here that module definition lists a few dependencies:</p>
<ul>
<li><a href="http://angular-ui.github.io/ui-router/site/#/api/ui.router">UI router</a> because its a better router.</li>
<li><a href="http://angular-ui.github.io/bootstrap/">UI bootstrap</a> for bootstrap components.</li>
</ul>
<p>These are satisfied by bower. If you look at the <code>bower.json</code> you will see them listed. The first place to start for any
new project is usually to sort out this list of dependencies. Each bower dependency is automatically injected into the
<code>index.html</code> during the build process.</p>
<h3 id="toc_3">Routes</h3>
<p>The routes are a key part of composition, for this project they happen to be found in <code>/todo/todo-routes.js</code>.</p>
<pre><code>/**
* &lt;p&gt;Routing for the to-do app.&lt;/p&gt;
* @ngInject
* @param {object} $StateProvider
* @param {object} $urlRouterProvider
*/
function todoRoutes($stateProvider, $urlRouterProvider) {
'use strict';
$urlRouterProvider.otherwise('/')
$stateProvider
.state('home', {
url: '/:status',
template: require('./view/todo.html'),
controller: require('./controller/todo-controller')
});
}
module.exports = todoRoutes;
</code></pre>
<p>This is a pretty simple example of <a href="http://angular-ui.github.io/ui-router/site/#/api/ui.router">UI-router</a>, with some
important distinctions.</p>
<ul>
<li><p>As with every file we will import into the composition root, we must use the explicit annotation <code>@ngInject</code>. This
is super important to ensure proper minification.</p></li>
<li><p>We can directly <code>require()</code> the template and controller items. We do not need to hack the template cache or map the
controller separately.</p></li>
</ul>
<p>Routes are also composition so there is no reason why this cannot be defined in-line in the composition root. Similarly,
you can split your composition root over several files as appropriate.</p>
<h3 id="toc_4">Directives</h3>
<p>Note that there are no directives in the local library, they are
<a href="https://docs.npmjs.com/files/package.json#bundleddependencies">bundled dependencies</a> in order to illustrate how a
library package may be used.</p>
<p>The todo project maps directives in a somewhat confusing way, but does so to illustrate an important point.</p>
<p>Each of the directives shown, <code>escapeKeyDirective</code> and <code>focusElementDirective</code> are invoked by attribute and need to read
a value from that attribute. However, in the configuration root we can map them against any attribute and need to tell
them what attribute that is.</p>
<p>The <code>forAttribute()</code> method is a factory for creating the directive. That way we can close it as
<code>focusElementDirective.forAttribute('focus')</code> and yield a function for mapping.</p>
<p>Lets take a closer look at that code.</p>
<pre><code>focusElementDirective.forAttribute = function forAttribute(attribute) {
return /** @ngInject */ function ($timeout) {
return focusElementDirective($timeout, attribute);
};
}
</code></pre>
<p>All that is happening is that we capture the given <code>attribute</code> name and pass it to the directive along with the injected
<code>$timeout</code> dependency.</p>
<p>Note the use of <code>@ngInject</code> comment inline, since it is the inner function that is provided to the Angular directive
map.</p>
<p>These implementations are maximally correct. In a practical situation you may prefer to avoid the <code>forAttribute()</code>
factory and just hard-code the directive to a particular element. In this case you must ensure you map the directive
against the same name in the composition root.</p>
<h3 id="toc_5">Factories and Services</h3>
<p>This example does not have and factories or services, but instead maps a <code>value()</code>. This is because the <code>LocalStorage</code>
component does not require any dependency injection and does require implementation. As such it perhaps a bad example.</p>
<p>Be that as it may, factories and services may be mapped just as easily by specifying an import.</p>
</description>
</item>
<item>
<title>Building Todo</title>
<link>/start/building/</link>
<pubDate>Mon, 15 Dec 2014 13:43:41 AEDT</pubDate>
<guid>/start/building/</guid>
<description>
<h2 id="toc_0">Test</h2>
<p>It is good to test <a href="https://angularjs.org/">AngularJS</a> applications. The Todo application implements only a couple of
tests but they are always nice to see running.</p>
<p>Run the <a href="/tasks/test"><code>test</code></a> task from the Todo project directory.</p>
<pre><code>angularity test
</code></pre>
<p>This will generate an <code>/app-test</code> directory and you should see a console output indicating all tests passing.</p>
<h2 id="toc_1">Build</h2>
<p>Run the <a href="/tasks/build"><code>build</code></a> task from the Todo project directory.</p>
<pre><code>angularity build
</code></pre>
<p>This will perform a one-time build in an <code>/app-build</code> directory. For development however, you will find more use in the
<a href="/tasks/watch"><code>watch</code></a> task.</p>
<h2 id="toc_2">Watch</h2>
<p>The <a href="/tasks/watch"><code>watch</code></a> task is best for normal development.</p>
<pre><code>angularity watch
</code></pre>
<p>It is similar to the <a href="/tasks/build"><code>build</code></a> task. However it also watches your project for changes and serves the
project on a <code>localhost</code> port. For the Todo application this is port <code>55555</code>.</p>
<p>Navigate your browser to <a href="http://localhost:55555"><code>http://localhost:55555</code></a> and you will see a rudimentary Todo
application.</p>
<h2 id="toc_3">Release</h2>
<p>The <a href="/tasks/release"><code>release</code></a> task creates a set of deployment of files.</p>
<pre><code>angularity release
</code></pre>
<p>This will generate an <code>/app-release</code> directory with a maximally flat set of files for deployment.</p>
</description>
</item>
<item>
<title>Using Webstorm</title>
<link>/start/webstorm/</link>
<pubDate>Mon, 15 Dec 2014 13:43:41 AEDT</pubDate>
<guid>/start/webstorm/</guid>
<description>
<blockquote>
<p>Angularity favours development in the <a href="https://www.jetbrains.com/webstorm/">Webstorm IDE</a>. In time we hope to
similarly support other popular IDEs. If you don&rsquo;t use Webstorm you may skip this section.</p>
</blockquote>
<p>Ensure that the <a href="https://www.jetbrains.com/webstorm/">Webstorm IDE</a> is <strong>not running</strong>.</p>
<p>Run the <a href="/tasks/test"><code>webstorm</code></a> task from the Todo project directory.</p>
<pre><code>angularity webstorm
</code></pre>
<p>This will initialise a Webstorm project and other non-project features. It will attempt to launch Webstorm with the new
project.</p>
<blockquote>
<p>If you have a standard installation path this should be automatic. Otherwise you will need to specify the path to the
executable. You should save this path as the default value using the <code>--defaults</code> flag. Refer to the
<a href="/tasks/test"><code>webstorm</code></a> task for more information.</p>
</blockquote>
<h2 id="toc_0">Tools</h2>
<p>The <a href="/tasks/test"><code>webstorm</code></a> task will have added external tools that run Angularity build-related tasks.</p>
<p>Running tasks with these tools is superior to running from a terminal because Webstorm will <strong>hotlink</strong> filenames where
they appear, allowing you to go directly to the code.</p>
<p>You can find these under the <code>Tools</code> menu.</p>
<p><img src="/img/webstorm-external-tools.png" alt="new template" />
</p>
<p>The <code>watch</code> task should be your go-to for development. It builds and serves the application.</p>
<blockquote>
<p>Avoid using the <code>--unminified</code> option unless you are setting breakpoints (and need variable names to not be mangled by
minification). With source maps you should be running minified all the time. This avoids any surprises when you
release your application.</p>
</blockquote>
<p>Go ahead and select <code>Tools</code> &gt; <code>Angularity</code> &gt; <code>watch</code> so that we may run the application below.</p>
<h2 id="toc_1">Run</h2>
<p>The <a href="/tasks/test"><code>webstorm</code></a> task will have added debug settings for each application in your <code>/app</code> folder.</p>
<p>You can find these under the <code>Run</code> menu or opposite the breadcrumbs in the IDE header bar.</p>
<p><img src="/img/webstorm-run-config.png" alt="run configuration" />
</p>
<p>Go ahead and select <code>angularity-todo-es5</code> and hit the bug icon. This will launch your default browser to
<a href="http://localhost:55555"><code>http://localhost:55555</code></a> and you will see a rudimentary Todo application.</p>
<p>You will need to install the Jetbrains plugin in order for Webstorm to connect its debugger.</p>
<h2 id="toc_2">Templates</h2>
<p>The <a href="/tasks/test"><code>webstorm</code></a> task adds some file templates consistent with Angularity style.</p>
<p>Choose a folder and <code>RIGHT-CLICK</code>. Choose <code>New</code> &gt; <code>angularity-*</code>.</p>
<p><img src="/img/webstorm-new-template.png" alt="new template" />
</p>
</description>
</item>
<item>
<title>Init</title>
<link>/tasks/init/</link>
<pubDate>Mon, 15 Dec 2014 13:43:30 AEDT</pubDate>
<guid>/tasks/init/</guid>
<description><pre><code> The &quot;init&quot; task initialises a blank project. The given options initialise
project defaults. Where omitted the global default will be in effect for the
project.
The following steps are taken. Some steps are gated by respective a flag.
Default options may be globally defined or reset using the --defaults
option.
* project directory exists, else create
* /app exists, else create
* /app/*.html exists, else create
* /app/*.scss exists, else create
* angularity.json exists, else create
* package.json exists, else create --npm
* bower.json exists, else create --bower
* karma.conf.js exists, else create --karma
* .jshintrc exists, else create --jshint
* .gitignore exists, else create --gitignore
* .editorconfig exists, else create --editorconfig
If a package.json is present initialisation will occur in the current
directory. Otherwise a sub-directory iscreated per the project name
Where run on an exising project existing files will not be altered, delete
existing files in order to change properties.
Both the npm and bower packages are initially set private which you will need
to clear in order to publish.
Examples:
angularity init -n todo -i webstorm Create &quot;todo&quot; and initialise webstorm
angularity init --defaults -n pending Change the name default to &quot;pending
angularity init --defaults reset Reset defaults
Options:
--help, -h, -? This help message
--defaults, -z Set defaults
--name, -n The project name [default: &quot;my-project&quot;]
--version, -v The project version [default: &quot;0.0.0&quot;]
--description, -d The project description [default: &quot;&quot;]
--tag, -t A project tag [default: ]
--port, -p A port for the development web server [default: &quot;random&quot;]
--npm Create package.json [default: true]
--bower Create bower.json [default: true]
--karma Create karma.conf.js [default: true]
--jshint Create .jshintrc [default: true]
--gitignore Create .gitignore [default: true]
--editorconfig Create .editorconfig [default: true]
</code></pre>
</description>
</item>
<item>
<title>Build</title>
<link>/tasks/build/</link>
<pubDate>Mon, 15 Dec 2014 13:43:30 AEDT</pubDate>
<guid>/tasks/build/</guid>
<description><pre><code> The &quot;build&quot; task performs a single build of the javascript and SASS
composition root(s).
Examples:
angularity build Run this task
angularity build -u Run this task but do not minify javascript
Options:
--help, -h, -? This help message
--unminified, -u Inhibit minification of javascript [default: false]
--jshint-reporter, -j Specify a custom JsHint reporter to use. Either a
locally npm installed module, or the absolute path to
one. [default: &quot;angularity-jshint-reporter&quot;]
</code></pre>
</description>
</item>
<item>
<title>Watch</title>
<link>/tasks/watch/</link>
<pubDate>Mon, 15 Dec 2014 13:43:30 AEDT</pubDate>
<guid>/tasks/watch/</guid>
<description><pre><code> The &quot;watch&quot; task performs an initial build and then serves the application on
localhost at the given port. It then watches the project and performs rebuild
of Javascript and/or SASS compositions upon change. This is followed by HTML
injection and browser reload.
Examples:
angularity watch Run this task
angularity watch -p 8080 Run this task and serve at http://localhost:8080
angularity watch -n Run this task but do not minify javascript
Options:
--help, -h, -? This help message
--unminified, -u Inhibit minification of javascript [default: false]
--port, -p A port for the development web server [default: 55555]
--jshint-reporter, -j Specify a custom JsHint reporter to use. Either a
locally npm installed module, or the absolute path to
one. [default: &quot;angularity-jshint-reporter&quot;]
--karma-reporter, -k Specify a custom Karma reporter to use. Either a
locally npm installed module, or an asolute path to
one. [default: &quot;karma-angularity-reporter&quot;]
</code></pre>
</description>
</item>
<item>
<title>Test</title>
<link>/tasks/test/</link>
<pubDate>Mon, 15 Dec 2014 13:43:30 AEDT</pubDate>
<guid>/tasks/test/</guid>
<description><pre><code> The &quot;test&quot; task performs a one time build and karma test of all .spec.js
files in the project.
Examples:
angularity test Run this task
Options:
--help, -h, -? This help message
--jshint-reporter, -j Specify a custom JsHint reporter to use. Either a
locally npm installed module, or the absolute path to
one. [default: &quot;angularity-jshint-reporter&quot;]
--karma-reporter, -k Specify a custom Karma reporter to use. Either a
locally npm installed module, or an asolute path to
one. [default: &quot;karma-angularity-reporter&quot;]
</code></pre>
</description>
</item>
<item>
<title>Release</title>
<link>/tasks/release/</link>
<pubDate>Mon, 15 Dec 2014 13:43:30 AEDT</pubDate>
<guid>/tasks/release/</guid>
<description><pre><code> The &quot;release&quot; task performs a single build and exports the build files along
with bower components to a release directory.
Examples:
angularity release Run this task
angularity release -n Run this task but do not minify built javascript
Options:
--help, -h, -? This help message
--unminified, -u Inhibit minification of javascript [default: false]
--jshint-reporter, -j Specify a custom JsHint reporter to use. Either a
locally npm installed module, or the absolute path to
one. [default: &quot;angularity-jshint-reporter&quot;]
</code></pre>
</description>
</item>
<item>
<title>Webstorm</title>
<link>/tasks/webstorm/</link>
<pubDate>Mon, 15 Dec 2014 13:43:30 AEDT</pubDate>
<guid>/tasks/webstorm/</guid>
<description><pre><code> The &quot;webstorm&quot; task initialises webstorm for a project in the current working
directory and launches the IDE.
Where the IDE is installed in a non-standard location the full path to the
IDE should be used in place of the boolean in --launch.
The following steps are taken. Some steps are gated by respective a flag.
Default options may be globally defined or reset using the --defaults
option.
* Setup project (resources, debug config, suppressors) --project
* Create external tools that launch angularity --tools
* Set coding style rules --rules
* Add code templates --templates
* Launch IDE --launch
Examples:
angularity webstorm Run this task
angularity webstorm --defaults -l &lt;some-path&gt; Set a default executable path
angularity webstorm --defaults reset Reset defaults
Options:
--help, -h, -? This help message
--defaults, -z Set defaults
--subdir, -s Navigate to the sub-directory specified
--project, -p Setup project [default: true]
--tools, -t Install external tools [default: true]
--rules, -r Set style rules [default: true]
--templates, -t Add code templates [default: true]
--launch, -l Launch the IDE following setup [default: true]
</code></pre>
</description>
</item>
</channel>
</rss>