Git Product home page Git Product logo

cli's Introduction

Riot cli

Riot.js cli logo

Command line tool to precompile riot tags

Build Status Code Quality NPM version NPM downloads MIT License Coverage Status

Important

If you are using Riot.js < 4.0.0 please check the legacy branch

Installation

npm install @riotjs/cli -g

Usage

riot --help

cli's People

Contributors

cognitom avatar dependabot[bot] avatar gianlucaguarini avatar millette avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

riot cli in webstorm not compiling typescript with let or const

I am using riot cli in webstorm(don't think that matters), and I have a riot tag like this ->
<students_info> <div class="page_container" style=""> test </div> <script type="typescript"> let x = 1; </script> </students_info>
riot doesn't show any compile errors, but returns a js file with the word 'undefined' in it. if I change it to var it works. Other things like arrow functions and other things for typescript work fine as long as no let or const.

Print user-friendly compilation errors

$ riot tags --type es6
SyntaxError: unknown: Unexpected token (3:9)

Unable to debug errors based on such messages because (3:9) points to another line in original file.
Extend print with code output and filename like you did while tag syntax checking.

Watch new files

I'm using the following command with Riot CLI 4.0.2 to watch .riot changes in the src folder and write ES modules and maps back to the src folder. It works great except that new .riot files are not picked up. So I have to restart the command any time I add a new file.

npx riot -w src -o src --sourcemap file

My request is for riot to watch for new .riot files.

--watch not working on Windows

Trying to follow this tutorial about getting started with Riot. Was introduced to --watch, but it doesn't seem to do anything on my machine?

All it does is print out a "Watching" message, but it doesn't even compile the tags to begin with, let alone watch for any changes. I.e. after I run the command, I still have no index.js, and re-saving any files doesn't trigger anything either. ๐Ÿ˜Ÿ

capture

Zipped up code, in case structure has anything to do with it: riot-1.zip


riot-cli:      4.1.0 - https://github.com/riot/cli
riot-compiler: 3.5.1 - https://github.com/riot/compiler
windows:       10, Version 1803

can't compile tags on Windows

helpers.find(extRegex, from) always returns an empty array because TEMP_FILE_NAME.test(f) never match on Windows.

Typescript failing due to not using d.ts files.

I have some d.ts files, and I use them for my ts files. When I use a global variable like '_' in lodash in my tag files like so:
<students_info> <div class="page_container" style=""> test </div> <script type="typescript"> let x = _.map([1,2,3], (val) => { value+=1;}) ; </script> </students_info>
It fails because it doesn't know what lodash is with error: "Cannot find name _". I don't know how to get it to recognize my d.ts files. If I use declare var _; it compiles fine. But I don't want to have to create the d.ts files inside my tag files. Also, compiling from a regular ts file works fine.

Not sure if this is a bug or a feature request, or if I don't know how to properly add in the d.ts files, but couldn't find anything in the docs or SO.

I looked into typescript simple and noticed the heading "Ignore semantic errors" - Thought it may lead to the solution.

Empty output after compile in watch mode

Environment

OS: Linux 4.6.4
Node.js: 6.3.1
Riot: 2.6.1
Riot compiler: 2.5.3
Riot cli: 2.6.1

Also affects next branch.

General example

test.tag:

<test>
  <h3>Line</h3>
  <h3>Line</h3>
</test>

modifier.js:

var fs = require('fs');
fs.writeFileSync('test.tag', '<test>\n\t<h1>Changed</h1>\n</test>', 'utf-8');

Run riot -w test.tag. Then run node modifier.js.

Problem:
The output file tag.js is empty.

Practical example

Compiling pug templates to riot tag's, and making riot compile those tags in watch mode.

Cause

This is caused by chokidar using fs.watch instead of fs.watchFile.
Which causes a race condition, giving no input on fs.readFileSync.
This happens only when fs.writeFileSync or fs.writeFile are used.
Writing from cli via echo -e '<test>\n\t<h1>Changed</h1>\n</test>' > test.tag works as expected.

Possible fix

Use option usePolling: true when creating chokidar watcher.
I've verified setting this option fixes the issue.

Error: Cannot find module 'babylon'

The new @riotjs/compiler requires the babylon dependency somehow. The new CLI is somehow broken now due to the babel js internal dependencies

Cant use CLI without declaring devDependency

As of version 5.2.1 the pre-compilation of a simple .riot file with this command worked fine:

riot .

In 5.3.0 I have to declare @riotjs/cli as a devDependency despite not using any pre-processors at all, else it will throw a error about missing babel dependencies:

A critical error occurred
Trace: Error: Cannot find module '@babel/preset-typescript'
Require stack:
- C:\Users\xyz\AppData\Roaming\npm\node_modules\@riotjs\cli\node_modules\@babel\core\lib\config\files\plugins.js
- C:\Users\xyz\AppData\Roaming\npm\node_modules\@riotjs\cli\node_modules\@babel\core\lib\config\files\index.js
- C:\Users\xyz\AppData\Roaming\npm\node_modules\@riotjs\cli\node_modules\@babel\core\lib\index.js
- C:\Users\xyz\AppData\Roaming\npm\node_modules\@riotjs\cli\node_modules\@rollup\plugin-babel\dist\index.js
- C:\Users\xyz\AppData\Roaming\npm\node_modules\@riotjs\cli\cli.js

...

I am not using riot.js in a node project and @riotjs/cli was installed via npm globally.

Is there any plan to include these dependencies into the cli directly or is this the devDependency a requirement now?

Doesn't seem to compile folders

Installed the latest version or riot cli and it works for individual files just fine, but when I give it a folder, it doesn't do anything and doesn't say anything.

image

Upgrading from v5 to v6

Help us to manage our issues by answering the following:

  1. Describe your issue:

After upgrading from v5 to v6 I got an error with the build config.

I had a config with export default, but changing it with module.exports the error has disappeared.

Another error is still occurring:

Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work

And I don't know how to fix it.

The previous error before this told me to install the package @babel/preset-typescript.

  1. Can you reproduce the issue?

The issue can be seen here

To see the error run:

yarn && npx lerna bootstrap && npx lerna run build
  1. On which browser/OS does the issue appear?

macOS

  1. Which version of Riot does it affect?

v6

  1. How would you tag this issue?
  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance

Messages with Node v10.0.0

I updated Node.js to v10.0.0, then the following message displayed.

(node:58855) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

macOS 10.13.4
Node 10.0.0
Yarn 1.6.2

riot -w does not show errors

Help us to manage our issues by answering the following:

  1. Describe your issue:

when I compile files with riot . then tag errors are displayed in the shell.
But when I compile with the watch mode riot -w . then no errors are displayed at all.
Iy would be perfect if the watch mode would display errors too

  1. Can you reproduce the issue?

make a syntax error in a tag so that git . shows the error description.
start it now with riot -w . and no error is displayed

  1. On which browser/OS does the issue appear?

in the shell

  1. Which version of Riot does it affect?

7.0.6

  1. How would you tag this issue?
  • Question
  • [ X] Bug
  • Discussion
  • [ X] Feature request
  • Tip
  • Enhancement
  • Performance

Error when trying to watch dir of riot files

riot --version
5.0.0

Here is what I'm trying to do

riot -e riot  -o js/components/ --watch riot

Now the output

Watching... riot/jobview.riot
Unknown input options: sourcemap, riot. Allowed options: acorn, acornInjectPlugins, cache, context, experimentalCacheExpiry, external, inlineDynamicImports, input, manualChunks, moduleContext, onwarn, perf, plugins, preserveEntrySignatures, preserveModules, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch

Failed to compile multiple riot components to a single js file

Hello, seems that options to compile all riot tags in a dir to a single concatenated file is not present/not supported in V4 ?
Options was :
riot foo/bar baz.js To a single concatenated file (baz.js)

when I try to use :
riot foo/bar baz.js
=> console shows each file .riot compiling to baz.js as expected
But when I have a look on output file baz.js it contains randomely some compiled tags, but not all.

Css preprocessor was not found. Have you installed it locally?"

Hello! :)

Sorry for my question. Sure I'm missing something simple.

The --style flag doesn't seem to work for me. --type and --template are ok.

I've installed all the parsers:

$ npm install babel jade coffee-script node-sass less

And tried all the flags;

$ riot src dist --type coffeescript

Works.

$ riot src dist --type babel

Works.

$ riot src dist --template jade

Works.

But...

$ riot src dist --style sass

"The "sass" css preprocessor was not found. Have you installed it locally?"

$ riot src dist --style less

"The "less" css preprocessor was not found. Have you installed it locally?"

I also tried:

$ riot src dist --type lessc

"The "lessc" javascript preprocessor was not found. Have you installed it locally?"

$ riot src dist --type node-sass

"The "node-sass" javascript preprocessor was not found. Have you installed it locally?"

What am I missing?

Thanks in advance.

write compilation errors to stderr

I'm using riot 2.6.0 and the riot command outputs both compilation errors and success messages to stdout. For better integration in my build chain, it would be awesome if errors could go to stderr instead.

Relying on the new riot-compiler

I will be able to start working on this riot submodule only when the new riot-compiler will be published on npm (at least a beta release).
@aMarCruz So this means that I would be really glad if you could ping me on here once you will have a stable release thanks.

install instructions not working in Windows 10

Thanks for the response.
The instructions don't work for me on Windows 10:
C:\Users\User>npm install @riotjs/cli -g
C:\Users\User\AppData\Roaming\npm\riot -> C:\Users\User\AppData\Roaming\npm\node_modules@riotjs\cli\index.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules@riotjs\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

C:\Users\User>riot --help
'riot' is not recognized as an internal or external command,
operable program or batch file.

Originally posted by @monkeysuffrage in #40 (comment)

Add a silent option

This is useful for build tools, so the console does not get messy with the compilation output.

cli ralways eturns exitcode 0 on errors

  1. Describe your issue:

compiling .riot file on the commandline returns always 0, even on errors.
This happens in the following cases:

for a nonexistent file:

$ ~/node_modules/.bin/riot none-xistent-file.riot
(node:25239) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat 'none-xistent-file'
at statSync (fs.js:915:3)
...

$ echo $?
0

and also if the file exists but has no root node:

$ touch foo.riot
$ ~/node_modules/.bin/riot foo.riot 
(node:25366) UnhandledPromiseRejectionWarning: Error: [1,0]: Root tag not found.
...

$ echo $?
0

Wishful bugfix: in case of an error, a not-zeroexitcode should be returned in the shell, so that the calling process can recognize the error

  1. Can you reproduce the issue?

yes, install riot cli v 4.0.3 ad do the steps in 1)

  1. Which version of Riot does it affect?

    $ ~/node_modules/.bin/riot -v
    4.0.3

  2. How would you tag this issue?

  • Question
  • [ X] Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance

Checking for tag errors doesn't work

At all

$ riot tags/home.tag --check
No syntax error. Ready to compile :)
$ cat tags/home.tag
<home>
    <div {>
    </div>

    const name = "R"
    ne,t setName =,%^; ( => {
    }
</home>

And even compilation works

$ riot tags/home.tag tags/home.js
tags/home.tag -> tags/home.js
$ cat tags/home.js
riot.tag2('home', '<div > </div>', '', '', function(opts) {

    const name = "R"
    ne,t setName =,%^; ( => {
    }
});

Version 5.1.0 breaks riot.config.js

I have two riot projects...

One project has these dependencies

"@riotjs/cli": "^5.0.0",
"@riotjs/compiler": "^5.1.3",
"chokidar-cli": "^2.1.0",
"concurrently": "^5.3.0",
"esbuild": "^0.8.26",
"riot": "^5.1.2",
"sass": "^1.32.5"

The other project has these dependencies

"@riotjs/cli": "^5.1.2",
"@riotjs/compiler": "^5.1.3",
"chokidar-cli": "^2.1.0",
"concurrently": "^5.3.0",
"esbuild": "^0.8.34",
"riot": "^5.1.4",
"sass": "^1.32.5"

Both projects have the exact same riot.config.js

import { registerPreprocessor } from '@riotjs/compiler'
import { dirname } from 'path'
import sass from 'sass'

registerPreprocessor('css', 'scss', function (code, { options }) {
  const { file } = options

  const { css } = sass.renderSync({
    data: code,
    includePaths: [dirname(file)]
  })

  return {
    code: css.toString(),
    map: null
  }
})

Both projects have the same npm build script

"build": "riot src/index.js -o public/app.js -c riot.config",

When I npm run build on the cli v5.0.0 project it works great. When I npm run build on the cli v5.1.2 project it errors out with this trace

% npm run build

> [email protected] build
> riot src/index.js -o public/app.js -c riot.config

It was not possible to load your config file, are you sure the path is correct?
A critical error occurred
Trace: /Users/xxxxxx/www/xxxxxx/riot.config.js:1
import { registerPreprocessor } from '@riotjs/compiler'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at loadConfig (/Users/xxxxx/www/xxxxxx/node_modules/@riotjs/cli/cli.js:291:10)
    at /Users/xxxxxx/www/xxxxxx/node_modules/cumpa/cumpa.js:24:48
    at /Users/xxxxxx/www/xxxxx/node_modules/cumpa/cumpa.js:24:46
    at panic (/Users/xxxxxx/www/xxxx/node_modules/@riotjs/cli/cli.js:32:5)
    at loadConfig (/Users/xxxxxx/www/xxxxx/node_modules/@riotjs/cli/cli.js:295:5)
    at /Users/xxxxx/www/xxxxx/node_modules/cumpa/cumpa.js:24:48
    at /Users/xxxxx/www/xxxxx/node_modules/cumpa/cumpa.js:24:46
    at run (/Users/xxxxx/www/xxxxx/node_modules/@riotjs/cli/cli.js:346:4)
    at Object.<anonymous> (/Users/xxxxx/www/xxxxx/node_modules/@riotjs/cli/cli.js:365:8)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
npm ERR! code 1
npm ERR! path /Users/xxxxx/www/xxxxx
npm ERR! command failed
npm ERR! command sh -c riot src/index.js -o public/app.js -c riot.config

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxxxx/.npm/_logs/2021-01-24T11_25_19_271Z-debug.log

The first obvious change I see from v5.0.0 to v 5.1.0 is the addition of a rollup.config.js file. https://github.com/riot/cli/blob/13c182de1ef0897df5bc596bda8fe619feb88153/rollup.config.js

If I npm remove @riotjs/cli in the newer project then npm i @riotjs/[email protected] it works again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.