startupjs 0.40.12 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dev ADDED
@@ -0,0 +1,127 @@
1
+ #!/bin/sh
2
+ # shellcheck disable=SC2059
3
+
4
+ # Exit on first failed command
5
+ set -e
6
+
7
+ # Run startupjs project using only Docker
8
+ #
9
+ # Version: 0.1.0
10
+ #
11
+ # Suports Mac, Linux, Windows WSL2
12
+ #
13
+ # Usage:
14
+ # ./dev - universal command to run the main terminal or spawn additional terminals.
15
+ # It tries to do the following:
16
+ # 1. Run the dev docker image of the same version of startupjs as in package.json.
17
+ # 2. If dev image is already running -- exec into it.
18
+
19
+ # Use current folder name as the name for container and the image by default
20
+ # ref: https://stackoverflow.com/a/43919044
21
+ a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; SCRIPT_DIR=$(cd "$a"; pwd)
22
+ FOLDER_NAME=$( basename "$SCRIPT_DIR" )
23
+
24
+ IMAGE_NAME="startupjs/dev"
25
+ CONTAINER_NAME="$FOLDER_NAME"
26
+
27
+ # Get startupjs version from package.json
28
+ STARTUPJS_VERSION=$( [ -f ./package.json ] && (grep -m 1 '"startupjs"' < ./package.json | sed -n 's/^[^"]*"[^"]*"[^"]*"//p' | sed -n 's/"[^"]*$//p') || echo '' )
29
+ STARTUPJS_VERSION=${STARTUPJS_VERSION:-latest}
30
+ # Remove leading ^ or ~ and remove the last patch number.
31
+ # This way ^0.40.2 will be converted to 0.40
32
+ # TODO: if yarn.lock exists, get the exact patch version from there
33
+ STARTUPJS_VERSION=$( echo "$STARTUPJS_VERSION" | sed -n 's/^[\^\~]*//p' | sed -n 's/\.*[0-9]*$//p' )
34
+
35
+ # Helper constants
36
+ ROOT="${PWD}"
37
+ # folder to store the MongoDB data
38
+ DB_FOLDER="${ROOT}/.mongo"
39
+ OS_NAME=$( uname -s | tr A-Z a-z )
40
+ # on Mac OS we use a faster driver for volume mounts
41
+ VOLUME_MODE=$( [ "$OS_NAME" = "darwin" ] && echo ":delegated" || echo "" )
42
+
43
+ # Colors
44
+ COLOR_NONE='\033[0m'
45
+ COLOR_LIGHT_GREEN='\033[1;32m'
46
+ COLOR_LIGHT_RED='\033[1;31m'
47
+
48
+ main () {
49
+ if docker ps | grep "\s${CONTAINER_NAME}$"; then
50
+ printf "${COLOR_LIGHT_GREEN}EXEC into the running container '${CONTAINER_NAME}'...${COLOR_NONE}\n"
51
+ _exec
52
+ else
53
+ printf "${COLOR_LIGHT_GREEN}RUN a new dev container '${CONTAINER_NAME}'...${COLOR_NONE}\n"
54
+ _cleanup
55
+ _run
56
+ fi
57
+ }
58
+
59
+ _exec () {
60
+ printf "${COLOR_LIGHT_GREEN}You are now inside the dev environment. Run your commands here:${COLOR_NONE}\n"
61
+ docker exec -it \
62
+ -e "CONTAINER_NAME=${CONTAINER_NAME}" \
63
+ "${CONTAINER_NAME}" \
64
+ bash
65
+ }
66
+
67
+ _run () {
68
+ PORT="${PORT:-$( _find_open_PORT )}"
69
+ DEV_PORT="${DEV_PORT:-$( _find_open_DEV_PORT )}"
70
+ if [ "$PORT" != "3000" ]; then
71
+ printf "${COLOR_LIGHT_RED}IMPORTANT: Default port 3000 was occupied. Your app got assigned the port ${PORT}${COLOR_NONE}!\n"
72
+ fi
73
+ printf "${COLOR_LIGHT_GREEN}You are now inside the dev environment. Run your commands here:${COLOR_NONE}\n"
74
+ echo "CONTAINER_NAME: $CONTAINER_NAME"
75
+ echo "PORT: $PORT"
76
+ echo "DEV_PORT: $DEV_PORT"
77
+ echo "ROOT: $ROOT"
78
+ echo "VOLUME_MODE: $VOLUME_MODE"
79
+ echo "HOME: $HOME"
80
+ echo "DB_FOLDER: $DB_FOLDER"
81
+ echo "IMAGE_NAME: $IMAGE_NAME"
82
+ echo "STARTUPJS_VERSION: $STARTUPJS_VERSION"
83
+ docker run --rm -it \
84
+ --name "${CONTAINER_NAME}" \
85
+ --pull=always \
86
+ -e "CONTAINER_NAME=${CONTAINER_NAME}" \
87
+ -e "DOCKER_HOST_PORT=${PORT}" \
88
+ --ulimit nofile=65535:65535 \
89
+ -p "${PORT}:3000" \
90
+ -p "${DEV_PORT}:3010" \
91
+ -v "${ROOT}:/ws${VOLUME_MODE}" \
92
+ -v "${HOME}/.ssh:/root/.ssh" \
93
+ -v "${HOME}/.gitconfig:/root/.gitconfig" \
94
+ -v "${DB_FOLDER}:/data/db${VOLUME_MODE}" \
95
+ "${IMAGE_NAME}:${STARTUPJS_VERSION}"
96
+ }
97
+
98
+ # Keep only 5 latest startupjs images you pulled. Remove older ones
99
+ # ref: https://stackoverflow.com/a/40892314
100
+ _cleanup () {
101
+ # shellcheck disable=SC2046
102
+ docker rmi $(docker images -q ${IMAGE_NAME} | tail -n +6) || true
103
+ }
104
+
105
+ # a bit hardcody way to get available port for the app. Start with 3000 and go up to 3009
106
+ _find_open_PORT () {
107
+ for iterator in 0 1 2 3 4 5 6 7 8 9; do
108
+ a_port="300${iterator}"
109
+ if ! lsof -n -i tcp:$a_port; then
110
+ echo $a_port
111
+ break
112
+ fi
113
+ done
114
+ }
115
+
116
+ # the same hardcody way as above to get available port for webpack devserver. Start with 3010 and go up to 3019
117
+ _find_open_DEV_PORT () {
118
+ for iterator in 0 1 2 3 4 5 6 7 8 9; do
119
+ a_port="301${iterator}"
120
+ if ! lsof -n -i tcp:$a_port; then
121
+ echo $a_port
122
+ break
123
+ fi
124
+ done
125
+ }
126
+
127
+ main "$@"; exit
package/index.d.ts CHANGED
@@ -4,5 +4,6 @@ export * from '@startupjs/hooks'
4
4
  // on the server and on the client
5
5
  export * from '@startupjs/isomorphic-helpers'
6
6
  // dummy babel macro functions for @startupjs/babel-plugin-rn-stylename-inline
7
- export function css (): void
8
- export function styl (): void
7
+ export function css (css: TemplateStringsArray): any
8
+ export function styl (styl: TemplateStringsArray): any
9
+ export function pug (pug: TemplateStringsArray): any
package/index.js CHANGED
@@ -4,6 +4,8 @@ export * from '@startupjs/hooks'
4
4
  // on the server and on the client
5
5
  export * from '@startupjs/isomorphic-helpers'
6
6
  // dummy babel macro functions for @startupjs/babel-plugin-rn-stylename-inline
7
- export function css () {}
8
- export function styl () {}
7
+ export function css (cssString) { return cssString }
8
+ export function styl (stylString) { return stylString }
9
+ // dummy pug function (it gets compiled to jsx by babel pug plugin)
10
+ export function pug (pugString) { return pugString }
9
11
  export { default as t } from '@startupjs/i18n/client/t.js'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "startupjs",
3
3
  "type": "module",
4
- "version": "0.40.12",
4
+ "version": "0.41.0",
5
5
  "engines": {
6
6
  "node": ">= 14"
7
7
  },
@@ -10,20 +10,20 @@
10
10
  "bin": "./cli.js",
11
11
  "license": "MIT",
12
12
  "dependencies": {
13
- "@startupjs/app": "^0.40.9",
14
- "@startupjs/backend": "^0.40.6",
15
- "@startupjs/bundler": "^0.40.9",
16
- "@startupjs/cli": "^0.40.6",
17
- "@startupjs/hooks": "^0.40.2",
18
- "@startupjs/i18n": "^0.40.0",
19
- "@startupjs/init": "^0.40.2",
20
- "@startupjs/isomorphic-helpers": "^0.40.0",
21
- "@startupjs/orm": "^0.40.0",
22
- "@startupjs/patches": "^0.40.0",
23
- "@startupjs/react-sharedb": "^0.40.2",
24
- "@startupjs/server": "^0.40.6",
25
- "babel-preset-startupjs": "^0.40.9",
13
+ "@startupjs/app": "^0.41.0",
14
+ "@startupjs/backend": "^0.41.0",
15
+ "@startupjs/bundler": "^0.41.0",
16
+ "@startupjs/cli": "^0.41.0",
17
+ "@startupjs/hooks": "^0.41.0",
18
+ "@startupjs/i18n": "^0.41.0",
19
+ "@startupjs/init": "^0.41.0",
20
+ "@startupjs/isomorphic-helpers": "^0.41.0",
21
+ "@startupjs/orm": "^0.41.0",
22
+ "@startupjs/patches": "^0.41.0",
23
+ "@startupjs/react-sharedb": "^0.41.0",
24
+ "@startupjs/server": "^0.41.0",
25
+ "babel-preset-startupjs": "^0.41.0",
26
26
  "react-native-web": "^0.14.3"
27
27
  },
28
- "gitHead": "61873f78477d54cad8c05b3f6f59cf8792bb46c0"
28
+ "gitHead": "3f2d1582418ddbb989fd48de6dbc2c6847f36f26"
29
29
  }
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import { Platform } from 'react-native'
3
3
  import init from 'startupjs/init'
4
4
  import App from 'startupjs/app'
5
- import { observer, model } from 'startupjs'
5
+ import { pug, observer, model } from 'startupjs'
6
6
  import { BASE_URL } from '@env'
7
7
  import orm from '../model'
8
8
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { View, TouchableOpacity, Text } from 'react-native'
3
- import { observer, emit } from 'startupjs'
3
+ import { pug, observer, emit } from 'startupjs'
4
4
  import './index.styl'
5
5
 
6
6
  export default observer(function ({ children }) {
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { Text, ScrollView } from 'react-native'
3
- import { observer } from 'startupjs'
3
+ import { pug, observer } from 'startupjs'
4
4
  import './index.styl'
5
5
 
6
6
  export default observer(function PAbout () {
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { ScrollView } from 'react-native'
3
- import { observer } from 'startupjs'
3
+ import { pug, observer } from 'startupjs'
4
4
  import { TestComponent } from 'components'
5
5
  import './index.styl'
6
6
 
@@ -15,7 +15,7 @@
15
15
  "Atomics": "readonly",
16
16
  "SharedArrayBuffer": "readonly"
17
17
  },
18
- "parser": "babel-eslint",
18
+ "parser": "@babel/eslint-parser",
19
19
  "parserOptions": {
20
20
  "ecmaFeatures": {
21
21
  "legacyDecorators": true,
@@ -15,7 +15,7 @@ RUN \
15
15
  # optionally use a custom npm token (if defined above)
16
16
  echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc && \
17
17
  # install build tools
18
- apk add --no-cache make gcc g++ python git && \
18
+ apk add --no-cache make gcc g++ python3 git && \
19
19
  # ffmpeg is required at runtime for video & audio conversion libraries
20
20
  apk add --no-cache ffmpeg && \
21
21
  # install dependencies
@@ -25,7 +25,7 @@ RUN \
25
25
  # cleanup yarn
26
26
  yarn cache clean && \
27
27
  # cleanup build tools
28
- apk del make gcc g++ python git
28
+ apk del make gcc g++ python3 git
29
29
 
30
30
  CMD yarn start-production
31
31
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { Platform } from 'react-native'
3
- import { observer, model } from 'startupjs'
3
+ import { pug, observer, model } from 'startupjs'
4
4
  import init from 'startupjs/init'
5
5
  import { BASE_URL } from '@env'
6
6
  import { TestComponent } from 'components'
@@ -5,6 +5,7 @@ import {
5
5
  TouchableOpacity
6
6
  } from 'react-native'
7
7
  import {
8
+ pug,
8
9
  observer,
9
10
  useDoc,
10
11
  useApi
@@ -0,0 +1,50 @@
1
+ #!/bin/sh
2
+ # shellcheck disable=SC2059
3
+
4
+ # Run startupjs project using only Docker
5
+ #
6
+ # Version: 0.1.0
7
+ #
8
+ # Suports Mac, Linux, Windows WSL2
9
+ #
10
+ # Usage:
11
+ # ./dev - universal command to run the main terminal or spawn additional terminals.
12
+ # It tries to do the following:
13
+ # 1. Run the dev docker image of the same version of startupjs as in package.json.
14
+ # 2. If dev image is already running -- exec into it.
15
+ #
16
+ # Note:
17
+ # This is a self-updating script, it will run the version of itself according to
18
+ # the startupjs version you have in your package.json
19
+
20
+ # Exit on first failed command
21
+ set -e
22
+
23
+ TMP_FILE=/tmp/startupjs.dev.sh
24
+
25
+ if [ -f ./node_modules/startupjs/dev ]; then
26
+ # if node_modules are already installed, run dev script from there
27
+ # TODO: Check if the startupjs version in node_modules matches the one in package.json, otherwise download script.
28
+ # shellcheck disable=SC1091
29
+ . ./node_modules/startupjs/dev
30
+ else
31
+ # otherwise try to download the according version (from package.json) from github and run it dynamically
32
+ if which curl; then
33
+ mkdir -p node_modules
34
+ STARTUPJS_VERSION=$( [ -f ./package.json ] && (grep -m 1 '"startupjs"' < ./package.json | sed -n 's/^[^"]*"[^"]*"[^"]*"//p' | sed -n 's/"[^"]*$//p') || echo 'latest' )
35
+ # Remove leading ^ or ~
36
+ STARTUPJS_VERSION=$( echo "$STARTUPJS_VERSION" | sed -n 's/^[\^\~]*//p' )
37
+ if [ "$STARTUPJS_VERSION" = "latest" ]; then
38
+ STARTUPJS_VERSION="master"
39
+ else
40
+ STARTUPJS_VERSION="v${STARTUPJS_VERSION}"
41
+ fi
42
+ printf "Downloading dev shell script from startupjs '${STARTUPJS_VERSION}' on github to ${TMP_FILE}\n"
43
+ curl -L "https://raw.githubusercontent.com/startupjs/startupjs/${STARTUPJS_VERSION}/packages/startupjs/dev" > $TMP_FILE
44
+ # shellcheck source=/dev/null
45
+ . $TMP_FILE
46
+ else
47
+ printf "ERROR! 'curl' not found. Please install it and run './dev' again\n"
48
+ exit 1
49
+ fi
50
+ fi
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "allowSyntheticDefaultImports": true,
5
+ "esModuleInterop": true,
6
+ "isolatedModules": true,
7
+ "jsx": "react",
8
+ "lib": ["es6"],
9
+ "moduleResolution": "node",
10
+ "noEmit": true,
11
+ "strict": false,
12
+ "target": "esnext"
13
+ },
14
+ "exclude": [
15
+ "node_modules",
16
+ "babel.config.js",
17
+ "metro.config.js",
18
+ "jest.config.js"
19
+ ]
20
+ }
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import { Platform } from 'react-native'
3
3
  import init from 'startupjs/init'
4
4
  import App from 'startupjs/app'
5
- import { observer, model } from 'startupjs'
5
+ import { pug, observer, model } from 'startupjs'
6
6
  import { registerPlugins } from 'startupjs/plugin'
7
7
  import { uiAppPlugin } from '@startupjs/ui'
8
8
  import { BASE_URL } from '@env'
@@ -1,9 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import {
3
- observer,
4
- useApi,
5
- useDoc
6
- } from 'startupjs'
2
+ import { pug, observer, useApi, useDoc } from 'startupjs'
7
3
  import { Br, Button, Card, Div, Row, Span } from '@startupjs/ui'
8
4
  import axios from 'axios'
9
5
  import { faPlus, faMinus } from '@fortawesome/free-solid-svg-icons'
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { observer, emit, useValue, useLocal } from 'startupjs'
2
+ import { pug, observer, emit, useValue, useLocal } from 'startupjs'
3
3
  import { Button, Div, H1, Layout, Menu, Row, SmartSidebar } from '@startupjs/ui'
4
4
  import { faBars } from '@fortawesome/free-solid-svg-icons'
5
5
  import APP from '../../app.json'
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { Text, ScrollView } from 'react-native'
3
- import { observer } from 'startupjs'
3
+ import { pug, observer } from 'startupjs'
4
4
  import { Content } from '@startupjs/ui'
5
5
  import './index.styl'
6
6
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { ScrollView } from 'react-native'
3
- import { observer } from 'startupjs'
3
+ import { pug, observer } from 'startupjs'
4
4
  import { Content } from '@startupjs/ui'
5
5
  import { TestComponent } from 'components'
6
6
  import './index.styl'
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env sh #
2
- @ 2>/dev/null # 2>nul & echo off #
3
- :; alias ::='' #
4
- :: #
5
- :: # Helper script to run StartupJS app using docker only
6
- :: # on both Unix and Windows.
7
- :: # version: 0.1.0
8
- :: #
9
- :: #
10
- :: # --- Bash script (Mac and Linux). Execute in bash console.
11
- :: #
12
- :: ROOT="${PWD}" #
13
- :: DB_FOLDER="${ROOT}/data" #
14
- :: APP_NAME="app" #
15
- :: DEV_IMAGE="startupjs/dev" #
16
- :: DEV_NAME="${APP_NAME}-dev" #
17
- :: OS_NAME=$( uname -s | tr A-Z a-z ) #
18
- :: VOLUME_MODE=$( [ "$OS_NAME" = "darwin" ] && echo ":delegated" || echo "" ) #
19
- :: #
20
- :: if [ -z "$1" ] || [ "$1" = "run" ]; then docker run --rm -it --name ${DEV_NAME} --ulimit nofile=65535:65535 -p 3000:3000 -p 3010:3010 -v ${DB_FOLDER}:/data/db${VOLUME_MODE} -v ${ROOT}:/ws${VOLUME_MODE} ${DEV_IMAGE}; #
21
- :: elif [ "$1" = "exec" ]; then docker exec -it ${DEV_NAME} sh; #
22
- :: else echo "Invalid command. Available:\n - run (default)\n - exec"; #
23
- :: fi #
24
- :: exit #
25
-
26
-
27
- :: # --- Batch script (Windows). Execute in cmd or in PowerShell.
28
- :: # TODO
29
-
30
- exit /B
@@ -1,60 +0,0 @@
1
- {
2
- "root": true,
3
- "env": {
4
- "browser": true,
5
- "es6": true,
6
- "node": true,
7
- "mocha": true
8
- },
9
- "extends": [
10
- "standard",
11
- "standard-react",
12
- "plugin:react-pug/all"
13
- ],
14
- "globals": {
15
- "Atomics": "readonly",
16
- "SharedArrayBuffer": "readonly"
17
- },
18
- "parser": "babel-eslint",
19
- "parserOptions": {
20
- "ecmaFeatures": {
21
- "legacyDecorators": true,
22
- "jsx": true
23
- },
24
- "ecmaVersion": 10,
25
- "sourceType": "module"
26
- },
27
- "plugins": [
28
- "react",
29
- "react-pug",
30
- "eslint-plugin-import-helpers"
31
- ],
32
- "rules": {
33
- "prefer-const": "off",
34
- "react/jsx-handler-names": "off",
35
- "react/prop-types": "off",
36
- "react-pug/empty-lines": "off",
37
- "react-pug/no-interpolation": "off",
38
- "react-pug/prop-types": "off",
39
- "react-pug/quotes": "off",
40
- "import-helpers/order-imports": [
41
- "warn",
42
- {
43
- "newlinesBetween": "ignore",
44
- "groups": [
45
- "/^react$/",
46
- "/react-native/",
47
- "/^react.*/",
48
- "/^startupjs/",
49
- "/^@?startupjs.*/",
50
- "/^@?dmapper.*/",
51
- "module",
52
- "/components/",
53
- ["/helpers/", "/hooks/"],
54
- ["sibling", "parent"],
55
- "/.\/index.styl/"
56
- ]
57
- }
58
- ]
59
- }
60
- }