https://github.com/treenotation/jtree/tree/master/langs/stamp Skip to content Sign up * Why GitHub? Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Project management - + Integrations - + GitHub Sponsors - + Customer stories - + Security - * Team * Enterprise * Explore + Explore GitHub - Learn & contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing Plans - + Compare plans - + Contact Sales - + Nonprofit - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} treenotation / jtree * Sponsor Sponsor treenotation/jtree * Watch 8 * Star 250 * Fork 8 * Code * Issues 33 * Pull requests 1 * Actions * Projects 7 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights master jtree/langs/stamp/ Go to file jtree/langs/stamp/ Latest commit @breck7 breck7 Add stamp link ... 97db3ed Feb 7, 2021 Add stamp link 97db3ed Git stats * History Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time . . tests Stamp improvements. Mk files recursively. Accept target dir. Improve ... Feb 7, 2021 readme.md Add stamp link Feb 7, 2021 sample.stamp CodeMirror now uses highlightscopes Apr 21, 2019 stamp.grammar Stamp improvements. Mk files recursively. Accept target dir. Improve ... Feb 7, 2021 readme.md Stamp First, show me some code folder myProject file myProject/index.js data console.log("Hello world") file myProject/readme.md data # My Readme You can also play with writing your own stamp files by hand in this web IDE to see autocomplete, type checking, and the full grammar. QuickStart: How to use Stamp in Node Stamp can be used in node to turn a folder on disk into a single stamp file, and to expand a single stamp file into a folder on disk. npm install jtree const stamp = require("jtree/products/stamp.nodejs.js") // Convert a folder to a stamp string: const stampString = stamp.dirToStampWithContents(__dirname) // Expand a stamp to disk new stamp(`file hello-world.txt`).execute() About Stamp is an alternative to zip files for sharing a small collection of folders and text files. A Stamp Program is an easily readable plain text program that when executed creates the files and folders listed. Stamp Programs can also prompt the user for input and use that input throughout the created files and folders. Frequently programmers have templates that they start new projects with. Those templates can be turned into Stamp programs. The Problem The web is full of project tutorials like this one that ask their readers to go through a series of steps to create a particular folder and file structure for a new project. The current options for this situation are: The Recipe Method - explain each step * Downside: If your basic project layout requires 10 files, that's 10 separate steps the reader has to do just to get started. * Downside: The reader might make an error during one of those steps and lose even more time. * Downside: Putting such steps in a narrative and updating that narrative if things change is time consuming as an author The Zip Method - zip the template directory * Downside: zip files are opaque and a user has no visibility into what they are creating * Downside: everytime the template changes, author has to rezip and reupload the folder * Downside: once unzipped, user has to manually change names to match the name of their project The Custom Utility Method - implement a custom command line program that generates new projects * Downside: No visibility into what is getting created * Downside: If the template changes, now author needs to get users to install the new template program * Downside: Now you have a whole new complicated program to write and maintain *The GitHub method - create a repo for your template and have people git clone it * Downside: no way of doing variable replacement post-clone * Downside: no plain text way of distributing the template Using Stamp on the command line npm install treeprogram npm install stamp-lang # todo: add automatic way to tell tree cli where stamp lang is ./exampleFile.stamp exampleFile.stamp #! /usr/local/bin/node --use_strict /usr/local/bin/tree folder myProject file myProject/index.js data console.log("Hello world") file myProject/readme.md data # My Readme exampleWithPrompt.stamp #! /usr/local/bin/node --use_strict /usr/local/bin/tree prompt PROJECTNAME any Enter a name for your project folder PROJECTNAME file PROJECTNAME/index.js data console.log("Hello world") file PROJECTNAME/readme.md data # PROJECTNAME Alternatives Considered * Wikipedia list of archive formats (https://en.wikipedia.org/wiki/ List_of_archive_formats) * ptar (https://github.com/jtvaughan/ptar) - full featured, but difference is the file output is a custom format (not a Tree Language) * shar (https://en.wikipedia.org/wiki/Shar) - old school method that has the major security flaw of potentially running any shell command * dar (http://dar.linux.free.fr/) * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.