Giter VIP home page Giter VIP logo

cli's Introduction

@enact/cli Travis NPM

A standalone toolkit for rapid Enact app development.

Installation

All that's needed to install @enact/cli is to use npm to install it globally. For Linux sudo may be required.

npm install -g @enact/cli

Note: Node 16 or greater required.

Creating a new App

The only time you're ever want to directly use the Enact CLI is when you want to create a new project.

enact create [directory]

This will generate a basic App template, complete with npm scripts and dependencies. If no directory path is specified, it will be generated within the working directory.

Advanced: If you've used npm link on separate installations of the Enact repo, you can run enact link afterwards to link in any available Enact libraries.

Available Commands

Enact supports several commands, each accessible through the enact command and through npm aliases in package.json. For help on individual commands, add --help following the command name. The commands are:

enact serve (aliased as npm run serve)

Builds and serves the app in the development mode.
Open http://localhost:8080 to view it in the browser.

The page will reload if you make edits.

enact pack (aliased as npm run pack, npm run pack-p, and npm run watch)

Builds the project in the working directory. Specifically, pack builds in development mode with code un-minified and with debug code included, whereas pack-p builds in production mode, with everything minified and optimized for performance. Be sure to avoid shipping or performance testing on development mode builds.

enact clean (aliased as npm run clean)

Deletes previous build fragments from ./dist.

enact lint (aliased as npm run lint)

Runs the Enact configuration of ESLint on the project for syntax analysis.

enact test (aliased as npm run test and npm run test-watch)

These tasks will execute all valid tests (files that end in -specs.js) that are within the project directory. The test is a standard single execution pass, while test-watch will set up a watcher to re-execute tests when files change.

enact license (aliased as npm run license)

Outputs a JSON representation of the licenses for modules referenced by the current project as well as any licenses of modules used by @enact/cli that may be included in a production build of an app.

Enact Build Options

The @enact/cli tool will check the project's package.json looking for an optional enact object for a few customization options:

  • template [string] - Filepath to an alternate HTML template to use with the Webpack html-webpack-plugin.
  • isomorphic [string] - Alternate filepath to a custom isomorphic-compatible entry point. Not needed if main entry point is already isomorphic-compatible.
  • title [string] - Title text that should be put within the HTML's <title></title> tags. Note: if this is a webOS-project, the title will, by default, be auto-detected from the appinfo.json content.
  • alias [object] - String mapping of webpack alias paths to use when building.
  • theme [object] - A simplified string name to extrapolate fontGenerator, ri, and screenTypes preset values from. For example, "sandstone".
  • fontGenerator [string] - Filepath to a CommonJS fontGenerator module which will build locale-specific font CSS to inject into the HTML. By default, will use any preset for a specified theme or fallback to sandstone.
  • ri [object] - Resolution independence options to be forwarded to the postcss-resolution-independence. By default, will use any preset for a specified theme or fallback to sandstone.
    • baseSize [number] - The root font-size to use when converting the value of the base unit to a resolution-independent unit. For example, when baseSize is set to 24, 48px in the LESS file will be converted to 2rem.
  • screenTypes [array|string] - Array of 1 or more screentype definitions to be used with prerender HTML initialization. Can alternatively reference a json filepath to read for screentype definitions. By default, will use any preset for a specified theme or fallback to sandstone.
  • nodeBuiltins [object] - Configuration settings for polyfilling NodeJS built-ins. See node webpack option.
  • resolveFallback [object] - Configuration settings for redirecting module requests when normal resolving fails. See resolve.fallback webpack option.
  • externalStartup [boolean] - Flag whether to externalize the startup/update js that is normally inlined within prerendered app HTML output.
  • forceCSSModules [boolean] - Flag whether to force all LESS/CSS to be processed in a modular context (not just the *.module.css and *.module.less files).
  • deep [string|array] - 1 or more JavaScript conditions that, when met, indicate deeplinking and any prerender should be discarded.
  • target [string|array] - A build-type generic preset string (see target webpack option) or alternatively a specific browserslist array of desired targets.
  • publicUrl [string] - Public path URL at which the app is served or destined to be hosted. This can also be set via the package.json homepage field.
  • proxy [string] - Proxy target during project serve to be used within the http-proxy-middleware.

For example:

{
	...
	"enact": {
		"theme": "sandstone",
		"resolveFallback": {
			fs: false,
			net: false,
			tls: false
		}
	}
	...
}

Displaying Lint Output in the Editor

Some editors, including Visual Studio Code, Sublime Text, and Atom provide plugins for ESLint.

They are not required for linting. You should see the linter output right in your terminal. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do.

You would need to install an ESLint plugin for your editor first.

Ever since ESLint 6, global installs of ESLint configs are no longer supported. To work around this new limitation, while still supporting in-editor linting, we've created a new eslint-config-enact-proxy package. The eslint-config-enact-proxy acts like a small proxy config, redirecting ESLint to use a globally-installed Enact ESLint config. eslint-config-enact-proxy needs to be installed locally on a project to enable in-editor linting:

npm install --save-dev eslint-config-enact-proxy

Also, you need to modify eslintConfig property in package.json:

  "eslintConfig": {
    "extends": "enact-proxy"
  },

NOTE: For strict mode, use "extends": "enact-proxy/strict".

In order for in-editor linting to work with our updated ESLint config, you'll need to upgrade to ESLint 7 or later. This can be installed globally by running:

npm install -g eslint

Then, you will need to uninstall any previous globally-installed Enact linting package (everything but eslint itself):

npm uninstall -g eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-babel @babel/eslint-parser eslint-plugin-jest eslint-plugin-enact eslint-config-enact

Documentation

Copyright and License Information

Unless otherwise specified, all content, including all source code files and documentation files in this repository are:

Copyright (c) 2016-2024 LG Electronics

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Portions of this project are based upon create-react-app, Copyright (C) 2016-present Facebook, Inc.

cli's People

Contributors

0x64 avatar aarontam avatar alexandrumorariu avatar enact-bot avatar germboy avatar github-actions[bot] avatar hong6316 avatar jaycanuck avatar juwonjeong avatar mikyungkim avatar renukaatale avatar rundmt avatar ryanjduffy avatar seunghoh avatar sjro avatar stanca-pop-lgp avatar sugardave avatar viodragon2 avatar webos101 avatar

Stargazers

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

Watchers

 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

https serve is not working

hi

in serve.js
function devServerConfig(host, protocol, publicPath, proxy, allowedHost) {
let https = false;
const {SSL_CRT_FILE, SSL_KEY_FILE} = process.env;
if (protocol === 'https' && [SSL_CRT_FILE, SSL_KEY_FILE].all(f => f && fs.existsSync(f))) {

all() is correct?
it should be changed to every().

Thanks.

Error When using enact create

I get the following error when trying to execute enact create test. The error does not occur if I revert to @enact/[email protected].

Creating a new Enact app in test...

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://[email protected]/enyojs/sandstone.git
npm ERR!
npm ERR! Warning: Permanently added the RSA host key for IP address *** to the list of known hosts.
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

TypeError: Cannot read property 'current' of undefined

Test/index.js

import React from 'react';
import PropTypes from 'prop-types';

const TestComp = ({value}) => {
        return (
                <div>
                        {value}
                </div>
        );
};

TestComp.propTypes = {
        value: PropTypes.string.isRequired,
};

export default TestComp;


Test/index.test.js

import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';

import Test from './index';

describe('st Test Cases', () => {
        it('matches snapshot', () => {
                const utils = render(
                        <Test
                                value={'on'}
                        />
                );
                expect(utils.container).toMatchSnapshot();
        });

});

I tried in latest cli 2.7.0
my steps..
$ enact create test
$ npm install react react-dom
$ npm install --save-dev @testing-library/jest-dom@testing-library/react
// add upper code(index.js) and test code(index.test.js)

enact test returns below errors
$ enact test

TypeError: Cannot read property 'current' of undefined

   7 | describe('st Test Cases', () => {
   8 |      it('matches snapshot', () => {
>  9 |              const utils = render(
     |                            ^
  10 |                      <Test
  11 |                              value={'on'}
  12 |                      />

  at act (../../../node_modules/react-dom/cjs/react-dom-test-utils.development.js:908:55)
  at render (../../../node_modules/@testing-library/react/dist/pure.js:82:26)
  at Object.it (index.test.js:9:17)

this is my package.json

        "dependencies": {
                "@enact/core": "^3.0.0",
                "@enact/i18n": "^3.0.0",
                "@enact/moonstone": "^3.0.0",
                "@enact/spotlight": "^3.0.0",
                "@enact/ui": "^3.0.0",
                "ilib": "^14.2.0",
                "prop-types": "^15.6.2",
                "react": "^16.13.1",
                "react-dom": "^16.13.1"
        },
        "devDependencies": {
                "@testing-library/jest-dom": "^5.3.0",
                "@testing-library/react": "^10.0.2"
        }

Error run serve

I create new project, after then run enact eject and package.json will be change
"scripts": {
"serve": "node ./scripts/serve.js",
"pack": "node ./scripts/pack.js",

But when run npm run serve which will show error 'SyntaxError: Unexpected token (19:2)
' at App.js
Please help me check it again! Maybe outupdate.
Current version enact cli: 2.0.2
Version enact in package.json:
"dependencies": {
"@babel/polyfill": "7.2.5",
"@enact/core": "^2.0.0",
"@enact/i18n": "^2.0.0",
"@enact/moonstone": "^2.0.0",
"@enact/spotlight": "^2.0.0",
"@enact/ui": "^2.0.0",
"prop-types": "^15.6.2",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"devDependencies": {
"@babel/core": "7.2.2",
"@babel/plugin-proposal-class-properties": "7.3.0",
"@babel/plugin-proposal-export-default-from": "7.2.0",
"@babel/plugin-proposal-export-namespace-from": "7.2.0",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-transform-react-inline-elements": "7.2.0",
"@babel/preset-env": "7.3.1",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "7.1.0",
"@enact/dev-utils": "2.1.0",
"@enact/template-moonstone": "2.3.1",
"acorn": "^6.0.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "24.1.0",
"babel-loader": "8.0.5",
"babel-plugin-dev-expression": "0.2.1",
"babel-plugin-dynamic-import-node": "2.2.0",
"case-sensitive-paths-webpack-plugin": "2.2.0",
"chai": "4.2.0",
"chalk": "2.4.2",
"cross-spawn": "6.0.5",
"css-loader": "2.1.0",
"dotenv": "6.2.0",
"dotenv-expand": "4.2.0",
"enzyme": "3.8.0",
"enzyme-adapter-react-16": "1.9.1",
"eslint": "5.13.0",
"eslint-config-enact": "1.4.1",
"eslint-loader": "2.1.2",
"eslint-plugin-babel": "5.3.0",
"eslint-plugin-enact": "0.1.3",
"eslint-plugin-jest": "22.3.0",
"eslint-plugin-react": "7.12.4",
"expose-loader": "0.7.5",
"file-loader": "3.0.1",
"filesize": "4.0.0",
"fork-ts-checker-webpack-plugin-alt": "0.4.14",
"fs-extra": "7.0.1",
"html-webpack-plugin": "4.0.0-alpha",
"identity-obj-proxy": "3.0.0",
"jest": "24.1.0",
"less": "3.9.0",
"less-loader": "4.1.0",
"license-checker": "25.0.1",
"mini-css-extract-plugin": "0.5.0",
"minimist": "1.2.0",
"optimize-css-assets-webpack-plugin": "5.0.1",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-global-import": "1.0.6",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.5.0",
"postcss-resolution-independence": "1.0.0",
"raw-loader": "1.0.0",
"react-dev-utils": "7.0.3",
"react-test-renderer": "16.8.1",
"resolution-independence": "1.0.0",
"resolve": "1.10.0",
"strip-ansi": "5.0.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "1.2.2",
"webpack": "4.29.3",
"webpack-dev-server": "3.1.14"
}

How to configure import alias

I wanted to add alias import in an Enact project: i configured the tsconfig.json like bellow:
{ "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", "paths": { "@App/*": ["./src/App/*"], "@Components/*": ["./src/Components/*"], "@Views/*": ["./src/Views/*"] }, }, "include": [ "src", "types" ] }

and i saw in readme that there is alias that can be added to the enact object in package.json:

"alias": { "@App/*": ["./src/App/*"], "@Components/*": ["./src/Components/*"], "@Views/*": ["./src/Views/*"] }

i don't if it's the right way to it or alias import is not available in Enact but when i make import like:
import MyComponent from '@Components/MyComponent
It said can't resolve @Components/MyComponent.

enact create doesn't create a webos-meta folder?

I'm following the tutorial at https://enactjs.com/docs/tutorials/setup/ to do some development on webOS.

As a sanity check, I'm just trying to install the very basic app that's generated by enact create my-app.

However, npm pack just creates a .tgz (perhaps to be expected), and ares-package ./my-app yields ares-package ./my-app ares-package ERR! *** ares-package: ERROR: '/Users/lase/Code/my-app' has no meta files such as appinfo.json.

Am I missing something? Do I need to add additional flags to generate the meta folder?

Convert aspect ratio from pixel to rem is not working on locally while build or serve app with Environment Variables

Dear Enact team,

I have already overridden the resolution for my monitor with a value like this

....
const screenTypes = [
    {"name": "hd", "pxPerRem": 16, "width": 1280, "height": 720, "aspectRatioName": "hdtv"},
    {"name": "fhd", "pxPerRem": 24, "width": 1920, "height": 1080, "aspectRatioName": "hdtv"},
    {"name": "uw-uxga", "pxPerRem": 24, "width": 2560, "height": 1080, "aspectRatioName": "cinema"},
    {"name": "wqhd", "pxPerRem": 32, "width": 3440, "height": 1440, "aspectRatioName": "cinema", "base": true},
    {"name": "uhd", "pxPerRem": 48, "width": 3840, "height": 2160, "aspectRatioName": "hdtv"},
    {"name": "uhd2", "pxPerRem": 96, "width": 7680, "height": 4320, "aspectRatioName": "hdtv"}
];

export default ThemeDecorator({noAutoFocus: true, ri: {screenTypes}}, MyApp);

My .env file

ENACT_RI='{"baseSize": 32}'

when I run npm run serve then the font-size base set by @enact/ui/resolution package is correct(32px), but all of the aspect ratios in my style file(*.module.less) are the wrong value(convert pixel to rem), I am using browser inspector to check the values, it always divides for 48.

I did some debugs on CLI then I see that Enact's CLI is using Webpack to bundle the modules and it is loading all of the environment variables here https://github.com/enactjs/cli/blob/master/config/webpack.config.js#L48 after we apply to enact meta configuration in option-parser.js in https://github.com/enactjs/dev-utils/blob/master/option-parser.js#L212, so ENACT_RI variable doesn't exist in process.env => it is not working.

How to fix it?

I think we should re-apply enact meta configuration after Webpack loads all of the configs from .env if any, should update webpack.config.js file as the code below:

....
// Load applicable .env files into environment variables.
require('./dotenv').load(app.context);

// apply with the latest version of .env if any
app.applyEnactMeta();
....

After I try to edit the config then it is working fine for me, how do you think? If I mistake something then feel free to let me know.

Thanks and Regards,

========================================
node: v18.12.1
@enact/cli: 5.1.0

Packaging ENACTJS app for LG TV publishing

I package EnactJS app with npm run pack and Use the LG TV CLI ares-package to package the dist folder into *.ipk file. I then install the *.ipk file to the LG TV with ares-install. However the app does not seem to be able to launch and run on the TV.

Here is the app-info JSON file.
{ "id": "com.mikedoconsulting.cctv", "version": "1.0.0", "vendor": "LGE-SVL", "type": "web", "main": "index.html", "title": "CCTV", "icon": "icon.png", "miniicon": "icon-mini.png", "largeIcon": "icon-large.png", "uiRevision": 2 }

Removing i18n files from output of enact pack?

Is there any way in enact cli to remove i18n files in order to reduce size of output? I'm making my app in Korean only but these files are always included in dist and they are much huge compared to main.js and main.css.

Hot reload changed locale files

Hi enact team,

I'm writing an enact app, it supports 2 languages. Every time I make changes in localization files (strings.json) and save, nothing happens, the changes not reload directly, so I have to enact serve again.
Is it possible to update locales without restarting node server? It's better if enact-cli could support this.

Thanks.

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.