Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node.jsではじめてのCLI

 Node.jsではじめてのCLI

2017/04/07 東京Node学園付属小学校 入学式 のLTスライドです。

Shingo Yamazaki

April 07, 2017
Tweet

More Decks by Shingo Yamazaki

Other Decks in Programming

Transcript

  1. Node.js Ͱ
    ͸͡Ίͯͷ CLI
    2017.4.7 ౦ژNodeֶԂ෇ଐখֶߍ ೖֶࣜ

    View Slide

  2. ࢁ㟒ɹਅޗ


    גࣜձࣾνʔϜεϐϦοτ

    ϑϩϯτΤϯυΤϯδχΞ
    • Salesforce ϓϥοτϑΥʔϜͰWebΞϓϦ։ൃͯ͠·͢
    • ৽όʔδϣϯΛ React/Redux Ͱ࡞͍ͬͯΔͱ͜ΖͰ͢
    • JavaScript ͸ॻ͖·͕͢ Node.js ͸ॳ৺ऀͰ͢
    ࣗݾ঺հ
    Twitter: zaki___yama


    Blog: http://dackdive.hateblo.jp/

    View Slide

  3. CLI Λ࡞Ζ͏ͱࢥͬͨ
    ܦҢ

    View Slide

  4. ܦҢ
    ϑϩϯτΤϯυͷίʔυ

    ʢ+4 $44 ը૾ FUDʣ
    όοΫΤϯυͷίʔυ
    ΦϒδΣΫτఆٛ
    9.-

    ݸʑਓͷ։ൃ؀ڥ
    ʢΫϥ΢υʣ
    ϩʔΧϧ1$
    SalesforceϓϥοτϑΥʔϜΛ࢖ͬͨΞϓϦ։ൃ
    σϓϩΠ
    (Git؅ཧ)
    ΦϒδΣΫτ%#ͷςʔϒϧ

    View Slide

  5. ΦϒδΣΫτఆٛ
    9.-

    ܦҢ
    ϑϩϯτΤϯυͷίʔυ

    ʢ+4 $44 ը૾ FUDʣ
    όοΫΤϯυͷίʔυ
    ϩʔΧϧ1$
    ։ൃΛ͍ͯͯͨ͠·ʹࢥ͏͜ͱ
    ͱ͋ΔΦϒδΣΫτͷεΩʔϚΛ
    ͬ͞ͱ֬ೝ͍ͨ͠ʂ
    ʢ͕ɺத਎͸9.-ʣ
    $47΍.BSLEPXOʹม׵ͯ͠
    ࢓༷ॻͳͲͷυΩϡϝϯτʹຒΊࠐΈ͍ͨ
    (Git؅ཧ)
    →πʔϧ࡞Εͳ͍͔ͳʁ

    View Slide

  6. • ΦϒδΣΫτఆٛϑΝΠϧͷύεΛࢦఆͯ͠
    • XML Λύʔεͯ͠
    • ݁ՌΛ Markdown ΍ CSV ʹม׵ͯ͠ग़ྗ
    ΍Γ͍ͨ͜ͱ

    View Slide

  7. • ೔ࠒ͔Β JavaScript Λॻ͍͍ͯΔ͔Β
    • npm ͰΠϯετʔϧͰ͖Δ = ಋೖͷෑډ͕௿ͦ͏
    ͔ͩͬͨΒ
    • gulp ͳͲͷπʔϧͱ૊Έ߹ΘͤΔ͜ͱ͕Ͱ͖ͦ͏
    ͔ͩΒ
    ͳͥɺNode.js?

    View Slide

  8. ॻ͍ͯΈΔ

    View Slide

  9. ͍ͪ͹Μ࠷ॳͷίʔυʢൈਮʣ

    View Slide

  10. ͍ͪ͹Μ࠷ॳͷίʔυʢൈਮʣ
    Ҿ਺͸
    QSPDFTTBSHW<>
    ͰऔΕΔ
    ग़ྗϑΥʔϚοτͷ੾ସ͸
    ؾʹͤͣ
    ͱΓ͋͑ͣ྆ํग़ͯ͠ΈΔ
    9.-ͷύʔε΍
    .BSLEPXO$47΁ͷม׵͸
    ύοέʔδʹ೚ͤΔ
    9.-ͷύʔε΍
    .BSLEPXO$47΁ͷม׵͸
    ϥΠϒϥϦʹ೚ͤΔ

    View Slide

  11. ݁Ռ
    Ͱ͖͚ͨͲɺϩʔΧϧͷεΫϦϓτϑΝΠϧΛ
    ௚઀ࢦఆ࣮ͯ͠ߦ͍ͯ͠Δঢ়ଶ

    View Slide

  12. ɹɹɹɹɹɹɹ
    Ͱ࢖͑ΔΑ͏ʹ͍ͨ͠
    $ npm install -g hoge

    View Slide

  13. CLIͱͯ͠ϦϦʔε͢Δ

    View Slide

  14. εΫϦϓτͷઌ಄ʹ̍ߦ௥Ճ
    ίϚϯυͰ࣮ߦՄೳʹ͢ΔͨΊͷ
    ͓·͡ͳ͍

    View Slide

  15. package.json ʹͪΐͬͱ௥ه
    άϩʔόϧΠϯετʔϧ
    OQNJHYYY

    Λਪ঑͢Δͱ͖͸هࡌ
    ࣮ࡍͷίϚϯυ໊ʹͳΔ෦෼
    $ npm install -g hoge

    View Slide

  16. npmjs.comʹΞΧ΢ϯτొ࿥

    View Slide

  17. $ npm adduser
    αΠϯΞοϓͨ͠ͱ͖ͷ
    ৘ใΛೖྗ͢Δ

    View Slide

  18. $ npm publish
    Ҏ߱͸Ξοϓσʔτͷͨͼʹ
    όʔδϣϯ্͛ͯ
    OQNQVCMJTI
    ͚ͩ

    View Slide

  19. Πϯετʔϧ

    View Slide

  20. Ͱ͖ͨ

    View Slide

  21. ΋͏ͪΐͬͱ
    ϒϥογϡΞοϓ

    View Slide

  22. minimist
    • https://github.com/substack/minimist
    • ΦϓγϣϯΛύʔεͯ͘͠ΕΔύοέʔδ
    Λύʔεͯ͠0CKFDUʹ
    -a bar --hoge=piyo

    View Slide

  23. • https://github.com/chalk/chalk
    • ίϯιʔϧग़ྗΛΧϥϑϧʹ

    View Slide

  24. ࠷ऴతʹ
    Τϥʔ͸੺৭Ͱදࣔ
    ɹɹɹɹͰ
    ग़ྗϑΥʔϚοτ
    ࢦఆՄೳʹ
    --format
    https://github.com/zaki-yama/parse-salesforce-object

    View Slide

  25. 2, 3࣌ؒͰ
    ͱΓ͋͑ͣ࢖͑Δ΋ͷ͕Ͱ͖ͨ

    View Slide

  26. • Node.jsͰCLIΛ࡞ͬͯΈͨ
    • ެ։͢Δͷ΋Πϯετʔϧͯ͠࢖ͬͯΈΔͷ΋؆୯
    • ΍Γ͍ͨ͜ͱͷେ൒͸ϥΠϒϥϦ͕طʹ͋Δ
    • TODOɿϔϧϓ࡞Γ͍ͨ

    ʢminimist ΑΓ Commandar.js ͩͬͨ…ʁʣ
    ·ͱΊ

    View Slide