Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update scaffolding for creating unary math iterator packages #2927

Merged
merged 27 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b301b79
chore: add runner script to create packages
gunjjoshi Sep 20, 2024
e065b72
Merge branch 'stdlib-js:develop' into math-iter-unary
gunjjoshi Sep 26, 2024
6522b2b
docs: update scaffold.sh
gunjjoshi Sep 27, 2024
ac6aacb
chore: update scaffold.sh
gunjjoshi Sep 27, 2024
d3c7b42
chore: update runner.js and scaffold.sh
gunjjoshi Sep 28, 2024
34d465c
Update scaffold.sh
gunjjoshi Sep 28, 2024
ae524f5
docs: update scaffold.sh
gunjjoshi Sep 29, 2024
7c65bac
Merge branch 'math-iter-unary' of https://github.com/gunjjoshi/stdlib…
gunjjoshi Sep 29, 2024
13cf609
chore: add keywords in the names array
gunjjoshi Sep 29, 2024
abbf3bc
Update lib/node_modules/@stdlib/_tools/scaffold/math-iter-unary/scrip…
gunjjoshi Oct 3, 2024
6067078
chore: move capitalizing logic to runner.js
gunjjoshi Oct 3, 2024
7079976
Apply suggestions from code review
kgryte Oct 4, 2024
2a94c9e
Apply suggestions from code review
kgryte Oct 4, 2024
3c0879e
refactor: fix environment variable logic and support specifying the b…
kgryte Oct 4, 2024
8be8688
style: remove unused variables
kgryte Oct 4, 2024
d780577
refactor: add support for specifying JavaScript return type
kgryte Oct 4, 2024
e0301aa
fix: update property access
kgryte Oct 4, 2024
c43e064
fix: update env var concat
kgryte Oct 4, 2024
ff2c1a8
refactor: clean up env var concat
kgryte Oct 4, 2024
d0448bb
refactor: update keywords and assertion methods
kgryte Oct 4, 2024
4acf56d
refactor: update default pkg desc
kgryte Oct 4, 2024
053de2c
fix: update link and handle decimal values
kgryte Oct 4, 2024
e4ed66d
refactor: add decimals for floating-point parameter values
kgryte Oct 4, 2024
474653b
style: disable lint rule
kgryte Oct 4, 2024
b40c84a
refactor: add comment indicating that files are generated
kgryte Oct 4, 2024
eae6a5c
build: don't overwrite by default
kgryte Oct 4, 2024
00eda1b
fix: update require path and ensure numeric type
kgryte Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env node

/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* 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.
*/

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var shell = require( 'child_process' ).execSync; // eslint-disable-line node/no-sync
var existsSync = require( '@stdlib/fs/exists' ).sync;
var objectKeys = require( '@stdlib/utils/keys' );
var uppercase = require( '@stdlib/string/base/uppercase' );
var rootDir = require( '@stdlib/_tools/utils/root-dir' );
var log = require( '@stdlib/console/log' );
var capitalize = require( '@stdlib/string/capitalize' );
var DATA = require( './data.json' );


// VARIABLES //

var CREATE_ONLY = 1;
var SCAFFOLD_SCRIPT = resolve( __dirname, 'scaffold.sh' );
var ROOT_DIR = resolve( rootDir(), 'lib', 'node_modules' );


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var names;
var keys;
var envs;
var str;
var cmd;
var p;
var k;
var v;
var o;
var i;
var j;

keys = objectKeys( DATA );
for ( i = 0; i < keys.length; i++ ) {
o = DATA[ keys[ i ] ];
p = resolve( ROOT_DIR, '@stdlib/math/iter/special', o.alias, 'package.json' );
if ( existsSync( p ) ) {
if ( CREATE_ONLY ) {
log( 'Package already exists. Skipping @%s...', 'stdlib/math/iter/special/' + o.alias );
continue;
}
log( 'Updating package: @%s...', 'stdlib/math/iter/special/' + o.alias );
} else {
log( 'Creating package: @%s...', 'stdlib/math/iter/special/' + o.alias );
}
names = [ 'base_alias', 'alias', 'pkg_desc', 'desc', 'example_values', 'rand', 'keywords' ];
envs = [];
for ( j = 0; j < names.length; j++ ) {
k = names[ j ];
v = o[ k ];
if ( k === 'example_values' ) {
envs.push( 'VALUES_LEN_2=\''+o.parameters[0].example_values.join(',')+'\'' );
continue;
} else if ( k === 'rand' ) {
envs.push( 'RAND_MIN='+o.parameters[0].rand.parameters[0] );
envs.push( 'RAND_MAX='+o.parameters[0].rand.parameters[1] );
continue;
} else if ( k === 'keywords' ) {
envs.push( 'KEYWORDS=\'' + o.keywords.join(',') + '\'' );
continue;
} else if ( k === 'alias' ) {
envs.push( 'ALIAS=iter' + capitalize( v ) );
continue;
} else {
str = uppercase( k );
str += '=';
str += '\'' + v + '\'';
}
envs.push( str );
}
cmd = envs.join( ' ' ) + ' . ' + SCAFFOLD_SCRIPT;
shell( cmd );
kgryte marked this conversation as resolved.
Show resolved Hide resolved
}
}

main();
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ alias=${ALIAS:-'iterTest'}

# Define the package description:
# shellcheck disable=SC2016
pkg_desc=${PKG_DESC:-'Create an iterator which computes `gamma(x+1) - 1` for each iterated value.'}
pkg_desc="Create an iterator which ${DESC:-'computes \`gamma(x+1) - 1\`'} for each iterated value."
kgryte marked this conversation as resolved.
Show resolved Hide resolved

# Define the module description:
# shellcheck disable=SC2016
module_desc=${MODULE_DESC:-'Create an iterator which iteratively computes `gamma(x+1) - 1`.'}
module_desc="Create an iterator which iteratively ${DESC:-'computes \`gamma(x+1) - 1\`'}."
kgryte marked this conversation as resolved.
Show resolved Hide resolved

# Define main export description:
# shellcheck disable=SC2016
main_desc=${MAIN_DESC:-'Returns an iterator which iteratively computes `gamma(x+1) - 1` without cancellation errors for small `x`.'}
main_desc="Returns an iterator which iteratively ${DESC:-'computes \`gamma(x+1) - 1\`'}."
kgryte marked this conversation as resolved.
Show resolved Hide resolved

# Define the test description:
# shellcheck disable=SC2016
test_desc=${TEST_DESC:-'computes `gamma(x+1) - 1` for each iterated value'}
test_desc=${DESC:-'computes \`gamma(x+1) - 1\`'}'for each iterated value'
kgryte marked this conversation as resolved.
Show resolved Hide resolved

# Define description text (found in the README) which should be a link to the unary package (NOTE: to not include a link, set to an empty string):
desc_link_text=${DESC_LINK_TEXT:-''}
Expand Down Expand Up @@ -147,7 +147,7 @@ unary_pkg_path="stdlib/math/base/special"
unary_pkg="${unary_pkg_path}/${unary_pkg_alias}"

# Define the REPL text main export description (note: 4 space indent and wrap at 80 characters):
repl_text_main_desc=$(echo -n "${main_desc}" | "${wrap}")
repl_text_main_desc=$(printf "%s" "${main_desc}" | "${wrap}")
repl_text_main_desc="${repl_text_main_desc/ /}"

# Define the copyright year:
Expand Down